hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Tool for parsing http request and response?
Date Fri, 27 Jul 2007 09:35:55 GMT
On Fri, 2007-07-27 at 11:10 +0200, Jeroen Verhagen wrote:
> Hi Roland and Oleg,
> 
> First thanks for you prompt reactions!
> 
> On 7/27/07, Oleg Kalnichevski <olegk@apache.org> wrote:
> >
> > There are plenty of test cases in HttpCore that make use of mock HTTP
> > connections (bound to a file or an array of bytes instead of a socket)
> > to exercise HTTP message parsing code. You could use those as a starting
> > point:
> 
> I found this testcase in the code:
> 
>     public void testSimpleParsing() throws Exception {
>         HttpParams params = new BasicHttpParams();
>         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 128);
>         HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
>         HttpRequestParser requestParser = new HttpRequestParser(inbuf,
> requestFactory, params);
>         requestParser.fillBuffer(newChannel("GET /whatever
> HTTP/1.1\r\nSome header: stuff\r\n\r\n"));
>         HttpRequest request = (HttpRequest) requestParser.parse();
>         assertNotNull(request);
>         assertEquals("/whatever", request.getRequestLine().getUri());
>         assertEquals(1, request.getAllHeaders().length);
>     }
> 
> This looks a lot like what I need for my case. I'm now convinced that
> your directions and HttpCore components I'm gonna solve my problem.
> Thanks!
> 

Jeroen,

Be careful. HttpCore supports two I/O models: classic blocking I/O and
non-blocking I/O (NIO). The test case you stumbled upon is for the NIO
transport. You may want to stick to somewhat simpler classic I/O model,
as the ability to process messages asynchronously does not seem to bring
much in your particular case.  

Oleg


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


Mime
View raw message