Discussion:
How replace the default HTTP URL handler in Java with one that uses the Apache HTTPClient?
Mats Eklund
2017-05-18 09:49:17 UTC
Permalink
Hi,

I am thinking of replacing the default HTTP connection handler in my Java web applications with one that uses Apache HTTPClient. The reason is that I want to leverage response caching of outbound HTTP requests made from my web application. The requests are made via various libraries, all using the standard java.net.URL class to access resources on the web.

Does the HTTP Components framework contain a ready to use solution for this, or are there some guidelines available for how to best go about it. I guess what I am looking for could be a common scenario! I found some possible directions here:

http://mjremijan.blogspot.co.at/2012/02/create-your-own-java-url-handlers.html

http://stackoverflow.com/questions/27993995/creating-httpurlconnection-for-urlstreamhandlerfactory-getting-error-protocol/28101085#28101085

But maybe there is already a ready to use component available, that could be simply dropped along with a configuration file for the caching behavior into the application's libraries folder?

Thanks so much in advance for any advice!

Mats
Oleg Kalnichevski
2017-05-19 07:33:21 UTC
Permalink
Post by Mats Eklund
Hi,
I am thinking of replacing the default HTTP connection handler in my
Java web applications with one that uses Apache HTTPClient. The
reason is that I want to leverage response caching of outbound HTTP
requests made from my web application. The requests are made via
various libraries, all using the standard java.net.URL class to
access resources on the web.
Does the HTTP Components framework contain a ready to use solution
for this, or are there some guidelines available for how to best go
about it. I guess what I am looking for could be a common scenario! I
http://mjremijan.blogspot.co.at/2012/02/create-your-own-java-url-hand
lers.html
http://stackoverflow.com/questions/27993995/creating-httpurlconnectio
n-for-urlstreamhandlerfactory-getting-error-
protocol/28101085#28101085
But maybe there is already a ready to use component available, that
could be simply dropped along with a configuration file for the
caching behavior into the application's libraries folder?
Thanks so much in advance for any advice!
Mats
A long time ago (more than 10 years back) there was an effort to
provide a HttpUrlConnection compatibility facade but it was eventually
abandoned as pointless. HttpUrlConnection APIs are so bad that is no
point supporting them. We might at some point look at providing a
compatibility layer for the coming HTTP client APIs in Java 1.9.

Oleg

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Mats Eklund
2017-05-19 13:27:21 UTC
Permalink
Hi Oleg,

Thanks for your reply.

So I guess I'd need to roll my own.

Not sure what you mean regarding the URLConnection API. The libraries in my project retrieve web resources by instantiating a java.net.URL object, and then calling one or two methods for retrieving the dereferenced resource on an input stream. It doesn't sound like it would be too complex, but maybe there is something in the details...?

Thanks,
Mats
Post by Mats Eklund
Hi,
I am thinking of replacing the default HTTP connection handler in my
Java web applications with one that uses Apache HTTPClient. The
reason is that I want to leverage response caching of outbound HTTP
requests made from my web application. The requests are made via
various libraries, all using the standard java.net.URL class to
access resources on the web.
Does the HTTP Components framework contain a ready to use solution
for this, or are there some guidelines available for how to best go
about it. I guess what I am looking for could be a common scenario! I
http://mjremijan.blogspot.co.at/2012/02/create-your-own-java-url-hand
lers.html
http://stackoverflow.com/questions/27993995/creating-httpurlconnectio
n-for-urlstreamhandlerfactory-getting-error-
protocol/28101085#28101085
But maybe there is already a ready to use component available, that
could be simply dropped along with a configuration file for the
caching behavior into the application's libraries folder?
Thanks so much in advance for any advice!
Mats
A long time ago (more than 10 years back) there was an effort to
provide a HttpUrlConnection compatibility facade but it was eventually
abandoned as pointless. HttpUrlConnection APIs are so bad that is no
point supporting them. We might at some point look at providing a
compatibility layer for the coming HTTP client APIs in Java 1.9.

Oleg

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Loading...