You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Michele Mancioppi <mi...@gmail.com> on 2012/07/18 16:44:51 UTC

Printing HttpMessage instances to a string

Hi all,


I was wondering what is the best way to marshall an HttpMessage (more
specifically, instances of HttpGet, HttpPost and HttpRequest) to a string.


I am using httpcore 4.0.1 and httpclient 4.1.


Thanks in advance,

Michele

Re: Printing HttpMessage instances to a string

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2012-07-18 at 16:44 +0200, Michele Mancioppi wrote:
> Hi all,
> 
> 
> I was wondering what is the best way to marshall an HttpMessage (more
> specifically, instances of HttpGet, HttpPost and HttpRequest) to a string.
> 
> 
> I am using httpcore 4.0.1 and httpclient 4.1.
> 
> 
> Thanks in advance,
> 
> Michele

Michele

I guess this pretty much depends on your specific use case and whether
you want to serialize message head (request line + headers) only or the
whole thing including a content body.

Take a look at the source of DefaultClientConnection and related
classes. This class can optionally write out the entire message to a
logging backend. You might want to re-use bits of it for your message
serializer.

Hope this helps

Oleg


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