How to get HTML content from HttpResponse?
Bruno de Carvalho
kindernade at gmail.com
Sun May 15 15:17:58 EDT 2011
When you receive a HttpResponse, you must create a new buffer (let's call it 'body') with the capacity announced in the Content-Length header - assuming it's greater than zero.
Then, for every HttpChunk you receive, you must append the contents of the chunk's buffer (chunk.getContent()) to 'body'. When you receive the last chunk (you it's the last when chunk.isLast() returns true) you can finally retrieve the contents of 'body' with something like:
body.toString(CharsetUtil.UTF_8); // this assumes the content is text...
Cheers,
Bruno
On May 15, 2011, at 3:03 PM, toshalex wrote:
> I am trying to write a small proxy to record information that is sent to my
> browser.
> I have a breakpoint in messageReceived() and the type of e.getMessage() is
> either HttpResponse or HttpChunk.
> How can I get the actual HTML from HttpResponse or HttpChunk?
> Thanks!
>
> --
> View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/How-to-get-HTML-content-from-HttpResponse-tp6365561p6365561.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
More information about the netty-users
mailing list