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 Brijesh Deo <bd...@SonicWALL.com> on 2009/07/28 15:13:41 UTC

question about saving the HttpEntity Content and later reproducing it

Hi Folks,

 

I have a requirement where I need to save the HttpEntity content from an
HttpRequest object when it is a POST or PUT operation. I am reading the
contents into a byte array and then saving it into a database table.
Later at some point, I would read it from the database, create
ByteArrayEntity instance from it and then create HttpPost or HttpPut
objects and use setEntity() to set the entity into the HttpPost or
HttpPut object. I have the following questions here:

 

1)       Will the HttpPost or HttpPut request object know if the
content-type is "application/x-www-form-urlencoded" or a
"multipart/form-data" or something else just by setting the HttpEntity
instance into it? Do I need to preserve the content-type beforehand
along with the Entity content and set it explicitly here?

 

2)       What are the http headers I need to preserve (generally with
respect to the Entity content) from the original HttpRequest object that
should be populated in the new HttpPost or HttpPut object so that it can
successfully be sent to a target server using an HttpClient instance? I
understand that headers like "Host", "Cookie" etc. might be different.

 

 

I'm hoping someone can help me out here.

 

Thanks,

Brijesh


Re: question about saving the HttpEntity Content and later reproducing it

Posted by Oleg Kalnichevski <ol...@apache.org>.
Brijesh Deo wrote:
> Hi Folks,
> 
>  
> 
> I have a requirement where I need to save the HttpEntity content from an
> HttpRequest object when it is a POST or PUT operation. I am reading the
> contents into a byte array and then saving it into a database table.
> Later at some point, I would read it from the database, create
> ByteArrayEntity instance from it and then create HttpPost or HttpPut
> objects and use setEntity() to set the entity into the HttpPost or
> HttpPut object. I have the following questions here:
> 
>  
> 
> 1)       Will the HttpPost or HttpPut request object know if the
> content-type is "application/x-www-form-urlencoded" or a
> "multipart/form-data" or something else just by setting the HttpEntity
> instance into it?

Depends on the HttpEntity implementation.


  Do I need to preserve the content-type beforehand
> along with the Entity content and set it explicitly here?
> 

Yes, you should.


>  
> 
> 2)       What are the http headers I need to preserve (generally with
> respect to the Entity content) from the original HttpRequest object that
> should be populated in the new HttpPost or HttpPut object so that it can
> successfully be sent to a target server using an HttpClient instance? I
> understand that headers like "Host", "Cookie" etc. might be different.
> 
>  

Only those exposed through the HttpEntity interface: content-type and 
content-encoding

Hope this helps

Oleg

> 
>  
> 
> I'm hoping someone can help me out here.
> 
>  
> 
> Thanks,
> 
> Brijesh
> 
> 


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