Ben Cox wrote:
Ah, getting there - almost! I was making the mistake of trying to cast the
InputStream of a BufferedHttpEntity. If I instead try
response.getEntity().getContent() (i.e. work with the BasicManagedEntity that
it gives me) I get an EofSensorInputStream which, I can see in debug, wraps a
ChunkedInputStream. However, the ChunkedInputStream is still invisible! Can I
somehow get access to that ChunkedInputStream?
You can get access to the underlying input stream from a response
interceptor:
-----
HttpHost targetHost = new HttpHost("www.yahoo.com", 80, "http");
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.addResponseInterceptor(new HttpResponseInterceptor() {
public void process(
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
context.setAttribute("raw-insteam", instream);
}
}
});
BasicHttpContext localcontext = new BasicHttpContext();
HttpGet httpget = new HttpGet("/");
HttpResponse response = httpclient.execute(targetHost, httpget,
localcontext);
System.out.println(response.getStatusLine());
HttpEntity entity = response.getEntity();
if (entity != null) {
entity.consumeContent();
}
InputStream instream = (InputStream)
localcontext.getAttribute("raw-insteam");
if (instream != null && instream instanceof ChunkedInputStream) {
Header[] footers = ((ChunkedInputStream) instream).getFooters();
System.out.println(footers.length);
}
---
Hope this helps
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]