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: persisting Response with HttpCore - implementing cache
Date Fri, 27 Jun 2008 18:14:09 GMT
On Fri, 2008-06-27 at 07:28 +0200, pluenl wrote:
> Oleg,
> 
> thank you for your help.
> Sorry that I didn't answer yet, but my time was short so that I could 
> have a look at all only yesterday.
> 
> Am I right that HttpWriter/HttpParser only process the headers and the 
> message body writing/parsing is done via Entity(De)Serializer?
> 

Yes, you are.

> I adopted the Buffer-Mockups to use FileOutputStream but I do not use 
> the AbstractHttpClientConnection.
> 
> I think the code I've implemented by now does what I need, but can you 
> please just have a look if there is a potentially problem in my code 
> e.g. use of internal API that may change?
> 

Looks all right to me

Oleg

> Thanks in advance
> Martin  
> 
> Here's the code extract (writing and reading response only):
> 
>             String filename = "c:/temp/response.txt";
> 
>             EntitySerializer serializer = new EntitySerializer(new 
> StrictContentLengthStrategy());
>             FileOutputStream fos = new FileOutputStream(filename);
>             SessionOutputBufferMockup sobm = new 
> SessionOutputBufferMockup(fos);
>             HttpResponseWriter writer = new HttpResponseWriter(sobm, 
> BasicLineFormatter.DEFAULT, new BasicHttpParams());
>             writer.write(response);
>             serializer.serialize(sobm, response, response.getEntity());
>             fos.close();
> 
>             EntityDeserializer entityDeserializer = new 
> EntityDeserializer(new LaxContentLengthStrategy());
>             FileInputStream fis = new FileInputStream(filename);
>             SessionInputBufferMockup sibm = new 
> SessionInputBufferMockup(fis, 1024);
>             HttpResponseParser responseParser = new HttpResponseParser(
>                 sibm,
>                 BasicLineParser.DEFAULT,
>                 new DefaultHttpResponseFactory(),
>                 new BasicHttpParams());
>            
>             response = (HttpResponse) responseParser.parse();
>             
> response.setEntity(entityDeserializer.deserialize(sibm,response));
>             fis.close();


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


Mime
View raw message