You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Juergen Weber <we...@gmail.com> on 2011/09/05 17:29:40 UTC

HttpClient as java.net.URLConnection

Hi,

I'd like to use HttpClient as a transport for the Hessian library. There is
a HessianConnectionFactory which returns a wrapped java.net.URLConnection. I
am thinking about writing a ConnectionFactory which returns a HttpClient
connection.

I was looking for an API in HttpClient to return a URLConnection, but there
is none, is there?

Thanks,
Juergen

http://www.caucho.com/resin-4.0-javadoc/com/caucho/hessian/client/HessianURLConnectionFactory.html


-- 
View this message in context: http://old.nabble.com/HttpClient-as-java.net.URLConnection-tp32401921p32401921.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: HttpClient as java.net.URLConnection

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2011-09-06 at 04:36 -0700, Juergen Weber wrote:
> >> It's just my guess that HttpURLConnection is a commonly used class, so it
> >> would offer itself to be replaced by another, better implementation.
> >
> > Yes, it is used a lot, but the API is very limited.
> > Replacing the implementation won't fix the API.
> 
> Limited it might be, but I guess HttpURLConnection is the defacto HTTP
> Client for Java (java HttpURLConnection gives 385.000 hits on google).
> 
> If HttpClient would provide a HttpURLConnection compatible implementation, 
> HttpClient could advertise with "Just plug in our HCHttpURLConnection and
> you get a better HttpURLConnection  without changing your code".
> 
> Many users would be happy with the HttpURLConnection API, if only
> HttpURLConnection would work with proxies and SSL without having to mess
> with System Properties and Authenticators. 
> 
> Thanks,
> Juergen

Juergen

You are very welcome to contribute such implementation. We'll happily
take it.

Oleg


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


Re: HttpClient as java.net.URLConnection

Posted by Juergen Weber <we...@gmail.com>.
>> It's just my guess that HttpURLConnection is a commonly used class, so it
>> would offer itself to be replaced by another, better implementation.
>
> Yes, it is used a lot, but the API is very limited.
> Replacing the implementation won't fix the API.

Limited it might be, but I guess HttpURLConnection is the defacto HTTP
Client for Java (java HttpURLConnection gives 385.000 hits on google).

If HttpClient would provide a HttpURLConnection compatible implementation, 
HttpClient could advertise with "Just plug in our HCHttpURLConnection and
you get a better HttpURLConnection  without changing your code".

Many users would be happy with the HttpURLConnection API, if only
HttpURLConnection would work with proxies and SSL without having to mess
with System Properties and Authenticators. 

Thanks,
Juergen
-- 
View this message in context: http://old.nabble.com/HttpClient-as-java.net.URLConnection-tp32401921p32407259.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: HttpClient as java.net.URLConnection

Posted by sebb <se...@gmail.com>.
On 5 September 2011 19:44, Juergen Weber <we...@gmail.com> wrote:
>
>> you're suggesting you wrap: HttpClient
>> classes > HttpURLConnection > HessianConnection. I don't see the point
>> in having HttpURLConnection in the mix. It adds an unnecessary level
>
> It's just my guess that HttpURLConnection is a commonly used class, so it
> would offer itself to be replaced by another, better implementation.

Yes, it is used a lot, but the API is very limited.
Replacing the implementation won't fix the API.

I had a look a another http implementation a while ago, and it had an
HttpURLConnection implementation.
IIRC it needed a fair amount of wrapper code. And of course the result
is not nearly as flexible.

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


Re: HttpClient as java.net.URLConnection

Posted by Vasile Alin <al...@gmail.com>.
On 5 September 2011 21:44, Juergen Weber <we...@gmail.com> wrote:
>
>> you're suggesting you wrap: HttpClient
>> classes > HttpURLConnection > HessianConnection. I don't see the point
>> in having HttpURLConnection in the mix. It adds an unnecessary level
>
> It's just my guess that HttpURLConnection is a commonly used class, so it
> would offer itself to be replaced by another, better implementation.

Since you return the functionality described by the HessianConnection
interface, wrapping the HttpClient classes should be enough.

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


Re: HttpClient as java.net.URLConnection

Posted by Juergen Weber <we...@gmail.com>.
> you're suggesting you wrap: HttpClient
> classes > HttpURLConnection > HessianConnection. I don't see the point
> in having HttpURLConnection in the mix. It adds an unnecessary level

It's just my guess that HttpURLConnection is a commonly used class, so it
would offer itself to be replaced by another, better implementation.

-- 
View this message in context: http://old.nabble.com/HttpClient-as-java.net.URLConnection-tp32401921p32403107.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: HttpClient as java.net.URLConnection

Posted by Sam Crawford <sa...@gmail.com>.
I speak only for myself of course, but what you're suggesting would
not be my favoured approach. You're suggesting you wrap: HttpClient
classes > HttpURLConnection > HessianConnection. I don't see the point
in having HttpURLConnection in the mix. It adds an unnecessary level
of complexity and it's interface would be restrictive (of course, you
could extend it, but then why not use HttpClient directly?).

Anyway, as you noted, if you wanted to proceed with this approach then
you could implement it yourself and use it with HessianConnection.

Thanks,

Sam



On 5 September 2011 18:40, Juergen Weber <we...@gmail.com> wrote:
>
>> HttpClient won't return a java.net.URLConnection instance - that's a
>> class from Java's built in (and woefully limited) HTTP client.
>
> Yes, but HttpURLConnection is abstract, so HttpClient could very well
> provide a derived class of HttpURLConnection.
>
>> However, looking at the Hessian API docs it doesn't appear that you
>> need to use java.net.URLConnection anyway. It looks like you need to
>> implement
>> http://www.caucho.com/resin-4.0-javadoc/com/caucho/hessian/client
>> /HessianConnectionFactory.html,
>> and this does not prescribe usage of java.net.URLConnection. It does
>> mention java.net.URL, but that's as an input and you can use this with
>> HttpClient if you wish.
>
> Yes, you're right, one could implement a HessianConnection based on
> HttpClient (and get the In/OutputStreams from HttpMethod), but I think a
> derived class of HttpURLConnection would be more generally useful (and also
> for the special usecase of HessianConnection)
>
> Thanks,
> Juergen
>
> --
> View this message in context: http://old.nabble.com/HttpClient-as-java.net.URLConnection-tp32401921p32402722.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

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


Re: HttpClient as java.net.URLConnection

Posted by Juergen Weber <we...@gmail.com>.
> HttpClient won't return a java.net.URLConnection instance - that's a
> class from Java's built in (and woefully limited) HTTP client.

Yes, but HttpURLConnection is abstract, so HttpClient could very well
provide a derived class of HttpURLConnection. 

> However, looking at the Hessian API docs it doesn't appear that you
> need to use java.net.URLConnection anyway. It looks like you need to
> implement
> http://www.caucho.com/resin-4.0-javadoc/com/caucho/hessian/client
> /HessianConnectionFactory.html,
> and this does not prescribe usage of java.net.URLConnection. It does
> mention java.net.URL, but that's as an input and you can use this with
> HttpClient if you wish.

Yes, you're right, one could implement a HessianConnection based on
HttpClient (and get the In/OutputStreams from HttpMethod), but I think a
derived class of HttpURLConnection would be more generally useful (and also
for the special usecase of HessianConnection)

Thanks,
Juergen

-- 
View this message in context: http://old.nabble.com/HttpClient-as-java.net.URLConnection-tp32401921p32402722.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: HttpClient as java.net.URLConnection

Posted by Sam Crawford <sa...@gmail.com>.
HttpClient won't return a java.net.URLConnection instance - that's a
class from Java's built in (and woefully limited) HTTP client.

However, looking at the Hessian API docs it doesn't appear that you
need to use java.net.URLConnection anyway. It looks like you need to
implement http://www.caucho.com/resin-4.0-javadoc/com/caucho/hessian/client/HessianConnectionFactory.html,
and this does not prescribe usage of java.net.URLConnection. It does
mention java.net.URL, but that's as an input and you can use this with
HttpClient if you wish.

Hope this helps,

Sam


On 5 September 2011 16:29, Juergen Weber <we...@gmail.com> wrote:
>
> Hi,
>
> I'd like to use HttpClient as a transport for the Hessian library. There is
> a HessianConnectionFactory which returns a wrapped java.net.URLConnection. I
> am thinking about writing a ConnectionFactory which returns a HttpClient
> connection.
>
> I was looking for an API in HttpClient to return a URLConnection, but there
> is none, is there?
>
> Thanks,
> Juergen
>
> http://www.caucho.com/resin-4.0-javadoc/com/caucho/hessian/client/HessianURLConnectionFactory.html
>
>
> --
> View this message in context: http://old.nabble.com/HttpClient-as-java.net.URLConnection-tp32401921p32401921.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

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