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 Todor Boev <ri...@gmail.com> on 2010/03/11 10:09:46 UTC
How to do cookies with NHttp*?
Hi,
I am working on an asynchronous HTTP client using the httpcore-nio library.
I need to do session management with cookies. I tried to do it like this:
// Make a request/response handler hooked to the executor
BasicHttpProcessor httpproc = new BasicHttpProcessor();
httpproc.addInterceptor(new RequestContent());
httpproc.addInterceptor(new RequestTargetHost());
httpproc.addInterceptor(new RequestConnControl());
httpproc.addInterceptor(new RequestUserAgent());
httpproc.addInterceptor(new RequestExpectContinue());
httpproc.addInterceptor(new RequestAddCookies()); // ADD COOKIES TO
REQUEST
httpproc.addInterceptor(new ResponseProcessCookies()); // PROCESS
COOKIES FROM RESPONSE
NHttpRequestExecutionHandler execHandler = new
NHttpRequestExecutionHandler(endpointUri, _cookies);
ThrottlingHttpClientHandler handler = new ThrottlingHttpClientHandler(
httpproc, //HOOK PROCESSOR TO HANDLER
execHandler,
new DefaultConnectionReuseStrategy(),
executor,
params);
To my distaste I discovered that ReequestAddCookies and
ResponseProcessCookies are coded agsinst the blocking HTTP API and
RequestAddCookies crashes with a ClassCastExceptions when it tries retrieve
a ManagedClientConnection from the HttpContext (and we have an
NHttpClientConnection there instead). The connection seems to be needed for
some trivial stuff: the remote port, and a http/https test.
My questions are:
1) Is there a ready-made way to do cookies with the asynchronous HTTP
client? Is there an async HTTP client library for example - couldn't find
one.
2) If I copy/paste RequestAddCookies and ResponseProcessCookies into my
classes and fix the trivial problems will I get a significatn performance
hit?
Cheers,
Todor
--
Go on! Destroy the fabric of the universe! See if I care!
Re: Classic I/O vs NIO comparison; was Re: How to do cookies with
NHttp*?
Posted by Todor Boev <ri...@gmail.com>.
On 14.03.2010 16:29, Oleg Kalnichevski wrote:
> Todor Boev wrote:
>> On 13.03.2010 18:59, Oleg Kalnichevski wrote:
>>> Ken Krugler wrote:
>>>> Hi Todor,
>>>>
>>> ...
>>>
>>>> I was hoping it might be related to nio vs. threaded approaches to
>>>> HTTP handling.
>>>>
>>>> There's been a lot of debate about the value (performance, simplicity,
>>>> resource consumption) but I haven't seen much head-to-head comparison
>>>> where the rest of the implementation is roughly comparable. If you
>>>> ever get any comparison numbers, I'd love to see them.
>>>>
>>>> -- Ken
>>>>
>>> I have made a number of tests comparing HttpCore blocking vs HttpCore
>>> NIO vs Jetty blocking vs Jetty NIO. The results and the link to the
>>> source code can be found here:
>>>
>>> http://wiki.apache.org/HttpComponents/HttpCoreBenchmark
>>
>> So NIO seems to be about 2 times slower than blocking I/O. What was
>> the number
>> of concurrent connections used? Seems the benefit of NIO is not it's
>> speed but
>> simply the ability to maintain 10,000 concurrent connections at a time.
>>
>
> The question is what is a legitimate use case for having to maintain so
> many concurrent connections? The only one I personally can think of is a
> proxy / gateway of some sort. I can cannot think of a single legitimate
> scenario where an HTTP agent would need to maintain more than a 100
> concurrent connections at most.
This same question has bothered me for the past few weeks. Given HTTP 1.1 allows
us to maintain only a few connections per remote host I can't think of a
scenario where we would not use connection pooling and blocking I/O.
>
> Besides, modern operating systems and JVMs got pretty efficient at
> context switching. I would not be very surprised if blocking I/O
> outperformed NIO even with several thousand of concurrent connections.
>
> NIO makes sense only when dealing with a _great_ number of _high
> latency_ connections, which most of the time stay idle waiting for a
> message to arrive.
Yup. I have used NIO in exactly this setting with a monitoring protocol that has
nothing to do with HTTP. I am starting to think the nature of HTTP makes NIO
useless for the client side. It is useful for the server side only because a
server must deal with unpredictable loads.
-- Todor
>
> Cheers
>
> Oleg
>
> ---------------------------------------------------------------------
> 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: Classic I/O vs NIO comparison; was Re: How to do cookies with
NHttp*?
Posted by Oleg Kalnichevski <ol...@apache.org>.
Todor Boev wrote:
> On 13.03.2010 18:59, Oleg Kalnichevski wrote:
>> Ken Krugler wrote:
>>> Hi Todor,
>>>
>> ...
>>
>>> I was hoping it might be related to nio vs. threaded approaches to
>>> HTTP handling.
>>>
>>> There's been a lot of debate about the value (performance, simplicity,
>>> resource consumption) but I haven't seen much head-to-head comparison
>>> where the rest of the implementation is roughly comparable. If you
>>> ever get any comparison numbers, I'd love to see them.
>>>
>>> -- Ken
>>>
>> I have made a number of tests comparing HttpCore blocking vs HttpCore
>> NIO vs Jetty blocking vs Jetty NIO. The results and the link to the
>> source code can be found here:
>>
>> http://wiki.apache.org/HttpComponents/HttpCoreBenchmark
>
> So NIO seems to be about 2 times slower than blocking I/O. What was the number
> of concurrent connections used? Seems the benefit of NIO is not it's speed but
> simply the ability to maintain 10,000 concurrent connections at a time.
>
The question is what is a legitimate use case for having to maintain so
many concurrent connections? The only one I personally can think of is a
proxy / gateway of some sort. I can cannot think of a single legitimate
scenario where an HTTP agent would need to maintain more than a 100
concurrent connections at most.
Besides, modern operating systems and JVMs got pretty efficient at
context switching. I would not be very surprised if blocking I/O
outperformed NIO even with several thousand of concurrent connections.
NIO makes sense only when dealing with a _great_ number of _high
latency_ connections, which most of the time stay idle waiting for a
message to arrive.
Cheers
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Classic I/O vs NIO comparison; was Re: How to do cookies with
NHttp*?
Posted by Chris Lowe <ch...@gmail.com>.
The benchmark results report a "Concurrency Level" of 25.
On 14 March 2010 13:29, Todor Boev <ri...@gmail.com> wrote:
> On 13.03.2010 18:59, Oleg Kalnichevski wrote:
>> Ken Krugler wrote:
>>> Hi Todor,
>>>
>>
>> ...
>>
>>>
>>> I was hoping it might be related to nio vs. threaded approaches to
>>> HTTP handling.
>>>
>>> There's been a lot of debate about the value (performance, simplicity,
>>> resource consumption) but I haven't seen much head-to-head comparison
>>> where the rest of the implementation is roughly comparable. If you
>>> ever get any comparison numbers, I'd love to see them.
>>>
>>> -- Ken
>>>
>>
>> I have made a number of tests comparing HttpCore blocking vs HttpCore
>> NIO vs Jetty blocking vs Jetty NIO. The results and the link to the
>> source code can be found here:
>>
>> http://wiki.apache.org/HttpComponents/HttpCoreBenchmark
>
> So NIO seems to be about 2 times slower than blocking I/O. What was the number
> of concurrent connections used? Seems the benefit of NIO is not it's speed but
> simply the ability to maintain 10,000 concurrent connections at a time.
>
> -- Todor
>
>>
>> Oleg
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Classic I/O vs NIO comparison; was Re: How to do cookies with
NHttp*?
Posted by Todor Boev <ri...@gmail.com>.
On 13.03.2010 18:59, Oleg Kalnichevski wrote:
> Ken Krugler wrote:
>> Hi Todor,
>>
>
> ...
>
>>
>> I was hoping it might be related to nio vs. threaded approaches to
>> HTTP handling.
>>
>> There's been a lot of debate about the value (performance, simplicity,
>> resource consumption) but I haven't seen much head-to-head comparison
>> where the rest of the implementation is roughly comparable. If you
>> ever get any comparison numbers, I'd love to see them.
>>
>> -- Ken
>>
>
> I have made a number of tests comparing HttpCore blocking vs HttpCore
> NIO vs Jetty blocking vs Jetty NIO. The results and the link to the
> source code can be found here:
>
> http://wiki.apache.org/HttpComponents/HttpCoreBenchmark
So NIO seems to be about 2 times slower than blocking I/O. What was the number
of concurrent connections used? Seems the benefit of NIO is not it's speed but
simply the ability to maintain 10,000 concurrent connections at a time.
-- Todor
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> 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: Classic I/O vs NIO comparison; was Re: How to do cookies with
NHttp*?
Posted by Chris Lowe <ch...@gmail.com>.
Fair enough. I was actually thinking about the request connection
overhead - I used to run Kaspersky as my AV (not recommended for
developers!) and it would additionally vet all connections.
Cheers for the info,
Chris.
On 13 March 2010 17:15, Oleg Kalnichevski <ol...@apache.org> wrote:
> Chris Lowe wrote:
>>
>> Nice work - I wonder what's going on with the Jetty NIO on Linux.
>>
>
> I know little about Jetty so it can well be it has not been configured in
> the best possible way. Optimizations are very welcome.
>
>
>> Out of curiosity - was there an AV product running at the time of the
>> Windows test?
>>
>
> I had Windows Defender set to off and no other AV running. It should not
> matter that much as the test case should perform no file system bound I/O
> (beyond normal class loading)
>
> Oleg
>
>> On 13 March 2010 16:59, Oleg Kalnichevski <ol...@apache.org> wrote:
>>>
>>> Ken Krugler wrote:
>>>>
>>>> Hi Todor,
>>>>
>>> ...
>>>
>>>> I was hoping it might be related to nio vs. threaded approaches to HTTP
>>>> handling.
>>>>
>>>> There's been a lot of debate about the value (performance, simplicity,
>>>> resource consumption) but I haven't seen much head-to-head comparison
>>>> where
>>>> the rest of the implementation is roughly comparable. If you ever get
>>>> any
>>>> comparison numbers, I'd love to see them.
>>>>
>>>> -- Ken
>>>>
>>> I have made a number of tests comparing HttpCore blocking vs HttpCore NIO
>>> vs
>>> Jetty blocking vs Jetty NIO. The results and the link to the source code
>>> can
>>> be found here:
>>>
>>> http://wiki.apache.org/HttpComponents/HttpCoreBenchmark
>>>
>>> Oleg
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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: Classic I/O vs NIO comparison; was Re: How to do cookies with
NHttp*?
Posted by Oleg Kalnichevski <ol...@apache.org>.
Chris Lowe wrote:
> Nice work - I wonder what's going on with the Jetty NIO on Linux.
>
I know little about Jetty so it can well be it has not been configured
in the best possible way. Optimizations are very welcome.
> Out of curiosity - was there an AV product running at the time of the
> Windows test?
>
I had Windows Defender set to off and no other AV running. It should not
matter that much as the test case should perform no file system bound
I/O (beyond normal class loading)
Oleg
> On 13 March 2010 16:59, Oleg Kalnichevski <ol...@apache.org> wrote:
>> Ken Krugler wrote:
>>> Hi Todor,
>>>
>> ...
>>
>>> I was hoping it might be related to nio vs. threaded approaches to HTTP
>>> handling.
>>>
>>> There's been a lot of debate about the value (performance, simplicity,
>>> resource consumption) but I haven't seen much head-to-head comparison where
>>> the rest of the implementation is roughly comparable. If you ever get any
>>> comparison numbers, I'd love to see them.
>>>
>>> -- Ken
>>>
>> I have made a number of tests comparing HttpCore blocking vs HttpCore NIO vs
>> Jetty blocking vs Jetty NIO. The results and the link to the source code can
>> be found here:
>>
>> http://wiki.apache.org/HttpComponents/HttpCoreBenchmark
>>
>> Oleg
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Classic I/O vs NIO comparison; was Re: How to do cookies with
NHttp*?
Posted by Chris Lowe <ch...@gmail.com>.
Nice work - I wonder what's going on with the Jetty NIO on Linux.
Out of curiosity - was there an AV product running at the time of the
Windows test?
On 13 March 2010 16:59, Oleg Kalnichevski <ol...@apache.org> wrote:
> Ken Krugler wrote:
>>
>> Hi Todor,
>>
>
> ...
>
>>
>> I was hoping it might be related to nio vs. threaded approaches to HTTP
>> handling.
>>
>> There's been a lot of debate about the value (performance, simplicity,
>> resource consumption) but I haven't seen much head-to-head comparison where
>> the rest of the implementation is roughly comparable. If you ever get any
>> comparison numbers, I'd love to see them.
>>
>> -- Ken
>>
>
> I have made a number of tests comparing HttpCore blocking vs HttpCore NIO vs
> Jetty blocking vs Jetty NIO. The results and the link to the source code can
> be found here:
>
> http://wiki.apache.org/HttpComponents/HttpCoreBenchmark
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> 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
Classic I/O vs NIO comparison; was Re: How to do cookies with NHttp*?
Posted by Oleg Kalnichevski <ol...@apache.org>.
Ken Krugler wrote:
> Hi Todor,
>
...
>
> I was hoping it might be related to nio vs. threaded approaches to HTTP
> handling.
>
> There's been a lot of debate about the value (performance, simplicity,
> resource consumption) but I haven't seen much head-to-head comparison
> where the rest of the implementation is roughly comparable. If you ever
> get any comparison numbers, I'd love to see them.
>
> -- Ken
>
I have made a number of tests comparing HttpCore blocking vs HttpCore
NIO vs Jetty blocking vs Jetty NIO. The results and the link to the
source code can be found here:
http://wiki.apache.org/HttpComponents/HttpCoreBenchmark
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: How to do cookies with NHttp*?
Posted by Ken Krugler <kk...@transpac.com>.
Hi Todor,
On Mar 13, 2010, at 5:19am, Todor Boev wrote:
> Ken Krugler wrote:
>>
>> On Mar 12, 2010, at 8:30am, Todor Boev wrote:
>>
>>> Did that...works just fine. 10x
>>
>> 10x what?
>
> 10x for pointing me to the low-level cookies stuff in HttpClient. I
> copied the
> code that sets up a CookieSpecRegistry from there. Than I made my
> version of
> RequestAddCookies that only use stuff from the blocking API. I
> reused the
> original RequestProcessCookies. Than all I had to do to get cookies
> to work is
> to place a CookieStore and a CookieSpecRegistry on the HttpContext
> as soon as a
> non-blocking http connection opens. Hope that answers your question.
Sure - looks like I'll have to brush up my net slang :)
I was hoping it might be related to nio vs. threaded approaches to
HTTP handling.
There's been a lot of debate about the value (performance, simplicity,
resource consumption) but I haven't seen much head-to-head comparison
where the rest of the implementation is roughly comparable. If you
ever get any comparison numbers, I'd love to see them.
-- Ken
>>> On Thu, Mar 11, 2010 at 9:06 PM, Oleg Kalnichevski
>>> <ol...@apache.org>
>>> wrote:
>>>
>>>> Todor Boev wrote:
>>>>
>>>>> Hi,
>>>>> I am working on an asynchronous HTTP client using the httpcore-nio
>>>>> library.
>>>>> I need to do session management with cookies. I tried to do it
>>>>> like
>>>>> this:
>>>>>
>>>>> // Make a request/response handler hooked to the executor
>>>>> BasicHttpProcessor httpproc = new BasicHttpProcessor();
>>>>> httpproc.addInterceptor(new RequestContent());
>>>>> httpproc.addInterceptor(new RequestTargetHost());
>>>>> httpproc.addInterceptor(new RequestConnControl());
>>>>> httpproc.addInterceptor(new RequestUserAgent());
>>>>> httpproc.addInterceptor(new RequestExpectContinue());
>>>>> httpproc.addInterceptor(new RequestAddCookies()); // ADD
>>>>> COOKIES TO
>>>>> REQUEST
>>>>> httpproc.addInterceptor(new ResponseProcessCookies()); //
>>>>> PROCESS
>>>>> COOKIES FROM RESPONSE
>>>>>
>>>>> NHttpRequestExecutionHandler execHandler = new
>>>>> NHttpRequestExecutionHandler(endpointUri, _cookies);
>>>>> ThrottlingHttpClientHandler handler = new
>>>>> ThrottlingHttpClientHandler(
>>>>> httpproc, //HOOK PROCESSOR TO HANDLER
>>>>> execHandler,
>>>>> new DefaultConnectionReuseStrategy(),
>>>>> executor,
>>>>> params);
>>>>>
>>>>> To my distaste I discovered that ReequestAddCookies and
>>>>> ResponseProcessCookies are coded agsinst the blocking HTTP API
>>>>> and
>>>>> RequestAddCookies crashes with a ClassCastExceptions when it tries
>>>>> retrieve
>>>>> a ManagedClientConnection from the HttpContext (and we have an
>>>>> NHttpClientConnection there instead). The connection seems to be
>>>>> needed
>>>>> for
>>>>> some trivial stuff: the remote port, and a http/https test.
>>>>>
>>>>> My questions are:
>>>>>
>>>>> 1) Is there a ready-made way to do cookies with the asynchronous
>>>>> HTTP
>>>>> client?
>>>>>
>>>>
>>>> No, currently there is not
>>>>
>>>>
>>>>
>>>> Is there an async HTTP client library for example - couldn't find
>>>>
>>>>> one.
>>>>>
>>>>
>>>> There is one, which is still in a very early stage of development
>>>>
>>>> http://svn.apache.org/repos/asf/httpcomponents/asynchttpclient/trunk/
>>>>
>>>>
>>>>
>>>> 2) If I copy/paste RequestAddCookies and ResponseProcessCookies
>>>> into my
>>>>> classes and fix the trivial problems will I get a significatn
>>>>> performance
>>>>> hit?
>>>>>
>>>>>
>>>> No, you will not. Just use low level cookie management code from
>>>> HttpClient
>>>> on top of HttpCore NIO and you will be just fine
>>>>
>>>> Oleg
>>>>
>>
>> --------------------------------------------
>> Ken Krugler
>> +1 530-210-6378
>> http://bixolabs.com
>> e l a s t i c w e b m i n i n g
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
--------------------------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c w e b m i n i n g
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: How to do cookies with NHttp*?
Posted by Todor Boev <ri...@gmail.com>.
Ken Krugler wrote:
>
> On Mar 12, 2010, at 8:30am, Todor Boev wrote:
>
>> Did that...works just fine. 10x
>
> 10x what?
10x for pointing me to the low-level cookies stuff in HttpClient. I copied the
code that sets up a CookieSpecRegistry from there. Than I made my version of
RequestAddCookies that only use stuff from the blocking API. I reused the
original RequestProcessCookies. Than all I had to do to get cookies to work is
to place a CookieStore and a CookieSpecRegistry on the HttpContext as soon as a
non-blocking http connection opens. Hope that answers your question.
-- Todor
>
> -- Ken
>
>> On Thu, Mar 11, 2010 at 9:06 PM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>>
>>> Todor Boev wrote:
>>>
>>>> Hi,
>>>> I am working on an asynchronous HTTP client using the httpcore-nio
>>>> library.
>>>> I need to do session management with cookies. I tried to do it like
>>>> this:
>>>>
>>>> // Make a request/response handler hooked to the executor
>>>> BasicHttpProcessor httpproc = new BasicHttpProcessor();
>>>> httpproc.addInterceptor(new RequestContent());
>>>> httpproc.addInterceptor(new RequestTargetHost());
>>>> httpproc.addInterceptor(new RequestConnControl());
>>>> httpproc.addInterceptor(new RequestUserAgent());
>>>> httpproc.addInterceptor(new RequestExpectContinue());
>>>> httpproc.addInterceptor(new RequestAddCookies()); // ADD COOKIES TO
>>>> REQUEST
>>>> httpproc.addInterceptor(new ResponseProcessCookies()); // PROCESS
>>>> COOKIES FROM RESPONSE
>>>>
>>>> NHttpRequestExecutionHandler execHandler = new
>>>> NHttpRequestExecutionHandler(endpointUri, _cookies);
>>>> ThrottlingHttpClientHandler handler = new
>>>> ThrottlingHttpClientHandler(
>>>> httpproc, //HOOK PROCESSOR TO HANDLER
>>>> execHandler,
>>>> new DefaultConnectionReuseStrategy(),
>>>> executor,
>>>> params);
>>>>
>>>> To my distaste I discovered that ReequestAddCookies and
>>>> ResponseProcessCookies are coded agsinst the blocking HTTP API and
>>>> RequestAddCookies crashes with a ClassCastExceptions when it tries
>>>> retrieve
>>>> a ManagedClientConnection from the HttpContext (and we have an
>>>> NHttpClientConnection there instead). The connection seems to be needed
>>>> for
>>>> some trivial stuff: the remote port, and a http/https test.
>>>>
>>>> My questions are:
>>>>
>>>> 1) Is there a ready-made way to do cookies with the asynchronous HTTP
>>>> client?
>>>>
>>>
>>> No, currently there is not
>>>
>>>
>>>
>>> Is there an async HTTP client library for example - couldn't find
>>>
>>>> one.
>>>>
>>>
>>> There is one, which is still in a very early stage of development
>>>
>>> http://svn.apache.org/repos/asf/httpcomponents/asynchttpclient/trunk/
>>>
>>>
>>>
>>> 2) If I copy/paste RequestAddCookies and ResponseProcessCookies into my
>>>> classes and fix the trivial problems will I get a significatn
>>>> performance
>>>> hit?
>>>>
>>>>
>>> No, you will not. Just use low level cookie management code from
>>> HttpClient
>>> on top of HttpCore NIO and you will be just fine
>>>
>>> Oleg
>>>
>
> --------------------------------------------
> Ken Krugler
> +1 530-210-6378
> http://bixolabs.com
> e l a s t i c w e b m i n i n g
>
>
>
>
>
> ---------------------------------------------------------------------
> 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: How to do cookies with NHttp*?
Posted by sebb <se...@gmail.com>.
On 12/03/2010, Ken Krugler <kk...@transpac.com> wrote:
>
> On Mar 12, 2010, at 8:30am, Todor Boev wrote:
>
>
> > Did that...works just fine. 10x
> >
>
> 10x what?
Seems to be Internet Slang for thanks:
http://topicpulse.com/articles/article/internet_slang_list/
Warning, some of the descriptions may be NSFW!
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: How to do cookies with NHttp*?
Posted by Ken Krugler <kk...@transpac.com>.
On Mar 12, 2010, at 8:30am, Todor Boev wrote:
> Did that...works just fine. 10x
10x what?
-- Ken
> On Thu, Mar 11, 2010 at 9:06 PM, Oleg Kalnichevski
> <ol...@apache.org> wrote:
>
>> Todor Boev wrote:
>>
>>> Hi,
>>> I am working on an asynchronous HTTP client using the httpcore-nio
>>> library.
>>> I need to do session management with cookies. I tried to do it
>>> like this:
>>>
>>> // Make a request/response handler hooked to the executor
>>> BasicHttpProcessor httpproc = new BasicHttpProcessor();
>>> httpproc.addInterceptor(new RequestContent());
>>> httpproc.addInterceptor(new RequestTargetHost());
>>> httpproc.addInterceptor(new RequestConnControl());
>>> httpproc.addInterceptor(new RequestUserAgent());
>>> httpproc.addInterceptor(new RequestExpectContinue());
>>> httpproc.addInterceptor(new RequestAddCookies()); // ADD
>>> COOKIES TO
>>> REQUEST
>>> httpproc.addInterceptor(new ResponseProcessCookies()); //
>>> PROCESS
>>> COOKIES FROM RESPONSE
>>>
>>> NHttpRequestExecutionHandler execHandler = new
>>> NHttpRequestExecutionHandler(endpointUri, _cookies);
>>> ThrottlingHttpClientHandler handler = new
>>> ThrottlingHttpClientHandler(
>>> httpproc, //HOOK PROCESSOR TO HANDLER
>>> execHandler,
>>> new DefaultConnectionReuseStrategy(),
>>> executor,
>>> params);
>>>
>>> To my distaste I discovered that ReequestAddCookies and
>>> ResponseProcessCookies are coded agsinst the blocking HTTP API and
>>> RequestAddCookies crashes with a ClassCastExceptions when it tries
>>> retrieve
>>> a ManagedClientConnection from the HttpContext (and we have an
>>> NHttpClientConnection there instead). The connection seems to be
>>> needed
>>> for
>>> some trivial stuff: the remote port, and a http/https test.
>>>
>>> My questions are:
>>>
>>> 1) Is there a ready-made way to do cookies with the asynchronous
>>> HTTP
>>> client?
>>>
>>
>> No, currently there is not
>>
>>
>>
>> Is there an async HTTP client library for example - couldn't find
>>
>>> one.
>>>
>>
>> There is one, which is still in a very early stage of development
>>
>> http://svn.apache.org/repos/asf/httpcomponents/asynchttpclient/trunk/
>>
>>
>>
>> 2) If I copy/paste RequestAddCookies and ResponseProcessCookies
>> into my
>>> classes and fix the trivial problems will I get a significatn
>>> performance
>>> hit?
>>>
>>>
>> No, you will not. Just use low level cookie management code from
>> HttpClient
>> on top of HttpCore NIO and you will be just fine
>>
>> Oleg
>>
--------------------------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c w e b m i n i n g
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: How to do cookies with NHttp*?
Posted by Todor Boev <ri...@gmail.com>.
Did that...works just fine. 10x
On Thu, Mar 11, 2010 at 9:06 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> Todor Boev wrote:
>
>> Hi,
>> I am working on an asynchronous HTTP client using the httpcore-nio
>> library.
>> I need to do session management with cookies. I tried to do it like this:
>>
>> // Make a request/response handler hooked to the executor
>> BasicHttpProcessor httpproc = new BasicHttpProcessor();
>> httpproc.addInterceptor(new RequestContent());
>> httpproc.addInterceptor(new RequestTargetHost());
>> httpproc.addInterceptor(new RequestConnControl());
>> httpproc.addInterceptor(new RequestUserAgent());
>> httpproc.addInterceptor(new RequestExpectContinue());
>> httpproc.addInterceptor(new RequestAddCookies()); // ADD COOKIES TO
>> REQUEST
>> httpproc.addInterceptor(new ResponseProcessCookies()); // PROCESS
>> COOKIES FROM RESPONSE
>>
>> NHttpRequestExecutionHandler execHandler = new
>> NHttpRequestExecutionHandler(endpointUri, _cookies);
>> ThrottlingHttpClientHandler handler = new
>> ThrottlingHttpClientHandler(
>> httpproc, //HOOK PROCESSOR TO HANDLER
>> execHandler,
>> new DefaultConnectionReuseStrategy(),
>> executor,
>> params);
>>
>> To my distaste I discovered that ReequestAddCookies and
>> ResponseProcessCookies are coded agsinst the blocking HTTP API and
>> RequestAddCookies crashes with a ClassCastExceptions when it tries
>> retrieve
>> a ManagedClientConnection from the HttpContext (and we have an
>> NHttpClientConnection there instead). The connection seems to be needed
>> for
>> some trivial stuff: the remote port, and a http/https test.
>>
>> My questions are:
>>
>> 1) Is there a ready-made way to do cookies with the asynchronous HTTP
>> client?
>>
>
> No, currently there is not
>
>
>
> Is there an async HTTP client library for example - couldn't find
>
>> one.
>>
>
> There is one, which is still in a very early stage of development
>
> http://svn.apache.org/repos/asf/httpcomponents/asynchttpclient/trunk/
>
>
>
> 2) If I copy/paste RequestAddCookies and ResponseProcessCookies into my
>> classes and fix the trivial problems will I get a significatn performance
>> hit?
>>
>>
> No, you will not. Just use low level cookie management code from HttpClient
> on top of HttpCore NIO and you will be just fine
>
> Oleg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
--
Go on! Destroy the fabric of the universe! See if I care!
Re: How to do cookies with NHttp*?
Posted by Oleg Kalnichevski <ol...@apache.org>.
Todor Boev wrote:
> Hi,
> I am working on an asynchronous HTTP client using the httpcore-nio library.
> I need to do session management with cookies. I tried to do it like this:
>
> // Make a request/response handler hooked to the executor
> BasicHttpProcessor httpproc = new BasicHttpProcessor();
> httpproc.addInterceptor(new RequestContent());
> httpproc.addInterceptor(new RequestTargetHost());
> httpproc.addInterceptor(new RequestConnControl());
> httpproc.addInterceptor(new RequestUserAgent());
> httpproc.addInterceptor(new RequestExpectContinue());
> httpproc.addInterceptor(new RequestAddCookies()); // ADD COOKIES TO
> REQUEST
> httpproc.addInterceptor(new ResponseProcessCookies()); // PROCESS
> COOKIES FROM RESPONSE
>
> NHttpRequestExecutionHandler execHandler = new
> NHttpRequestExecutionHandler(endpointUri, _cookies);
> ThrottlingHttpClientHandler handler = new ThrottlingHttpClientHandler(
> httpproc, //HOOK PROCESSOR TO HANDLER
> execHandler,
> new DefaultConnectionReuseStrategy(),
> executor,
> params);
>
> To my distaste I discovered that ReequestAddCookies and
> ResponseProcessCookies are coded agsinst the blocking HTTP API and
> RequestAddCookies crashes with a ClassCastExceptions when it tries retrieve
> a ManagedClientConnection from the HttpContext (and we have an
> NHttpClientConnection there instead). The connection seems to be needed for
> some trivial stuff: the remote port, and a http/https test.
>
> My questions are:
>
> 1) Is there a ready-made way to do cookies with the asynchronous HTTP
> client?
No, currently there is not
Is there an async HTTP client library for example - couldn't find
> one.
There is one, which is still in a very early stage of development
http://svn.apache.org/repos/asf/httpcomponents/asynchttpclient/trunk/
> 2) If I copy/paste RequestAddCookies and ResponseProcessCookies into my
> classes and fix the trivial problems will I get a significatn performance
> hit?
>
No, you will not. Just use low level cookie management code from
HttpClient on top of HttpCore NIO and you will be just fine
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org