You can wrap the HttpEntity in a BufferedHttpEntity and reuse that.

DefaultHttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet("http://www.somearbitraryurl.com";);
HttpResponse response = client.execute(get);
HttpEntity reusableEntity = new
BufferedHttpEntity(response.getEntity());

If you need to have it wrapped in a HttpResponse you can always try
and create an instance of BasicHttpResponse like so:

BasicHttpResponse reusableResponse = new
BasicHttpResponse(response.getStatusLine());
reusableResponse.setHeaders(response.getAllHeaders());
reusableResponse.setEntity(reusableEntity);

On 11 Apr, 11:35, mathcat <scien...@gmail.com> wrote:
> Hi geeks!
>
> As using the network package which apache provides, we usually do :
> HttpResponse resp = httpClient.execute(httpRequest);
>
> When I retrieve the HttpEntity object of the response, open the
> InputStream and extract the data in it, the HttpResponse object
> becomes unusable. If I try to do the thing again, exception occurs.
>
> Here I wish to reuse the HttpResponse, mostly for caching. But the
> HttpResponse object returned is type interface, I cannot call clone.
>
> Is there any way I can reuse the HttpResponse ?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to