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 "Kadlabalu, Hareesh" <ha...@fatwire.com> on 2005/07/24 19:28:07 UTC

PostMethod Vs MultipartPostMethod

Hello, 
I am trying to use PostMethod for sending multipart data using
PostMethod.setRequestEntity(..). I also want to conditionally add parameters
to it (using PostMethod.addParameter(..) ). However if I call
setRequestEntity() after calling addParameter(..), all parameters that are
set earlier are cleared. If I call the other way around, both are retained.

I searched the mail archives and came across a thread where it was suggested
that one must use MultipartPostMethod and send add whatever parameters I
would add as StringPart (along with any FilePart data).

However, MultipartPostMethod is deprecated and suggests the users to use
PostMethod instead. 

Given that I want to both addParameter() and multipart data, which approach
should I choose? It seems that for MultiPart posts, parameters are not
preferred? Is there a change in HTTP specs that forces this?

Thanks
-Hareesh


 


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


Re: PostMethod Vs MultipartPostMethod

Posted by Ortwin Glück <od...@odi.ch>.
Hareesh,

If you want to include both a file and "form" parameters in a post 
request you must use Multipart MIME and send both entities as separate 
MIME parts.

Ortwin Glück

Kadlabalu, Hareesh wrote:
> Hello, 
> I am trying to use PostMethod for sending multipart data using
> PostMethod.setRequestEntity(..). I also want to conditionally add parameters
> to it (using PostMethod.addParameter(..) ). However if I call
> setRequestEntity() after calling addParameter(..), all parameters that are
> set earlier are cleared. If I call the other way around, both are retained.
> 
> I searched the mail archives and came across a thread where it was suggested
> that one must use MultipartPostMethod and send add whatever parameters I
> would add as StringPart (along with any FilePart data).
> 
> However, MultipartPostMethod is deprecated and suggests the users to use
> PostMethod instead. 
> 
> Given that I want to both addParameter() and multipart data, which approach
> should I choose? It seems that for MultiPart posts, parameters are not
> preferred? Is there a change in HTTP specs that forces this?
> 
> Thanks
> -Hareesh


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


Re: PostMethod Vs MultipartPostMethod

Posted by Roland Weber <RO...@de.ibm.com>.
Hello Hareesh,

MultipartRequestEntity is what you are looking for, not
MultipartPostMethod.

Please avoid cross-posting to both our mailing lists.
Most developers will monitor the user list anyway
and those that don't do it for a reason.

cheers,
  Roland




"Kadlabalu, Hareesh" <ha...@fatwire.com> 
24.07.2005 19:28
Please respond to
"HttpClient User Discussion"


To
"Httpclient-Dev (E-mail)" <ht...@jakarta.apache.org>, 
"Httpclient-User List (E-mail)" <ht...@jakarta.apache.org>
cc

Subject
PostMethod Vs MultipartPostMethod






Hello, 
I am trying to use PostMethod for sending multipart data using
PostMethod.setRequestEntity(..). I also want to conditionally add 
parameters
to it (using PostMethod.addParameter(..) ). However if I call
setRequestEntity() after calling addParameter(..), all parameters that are
set earlier are cleared. If I call the other way around, both are 
retained.

I searched the mail archives and came across a thread where it was 
suggested
that one must use MultipartPostMethod and send add whatever parameters I
would add as StringPart (along with any FilePart data).

However, MultipartPostMethod is deprecated and suggests the users to use
PostMethod instead. 

Given that I want to both addParameter() and multipart data, which 
approach
should I choose? It seems that for MultiPart posts, parameters are not
preferred? Is there a change in HTTP specs that forces this?

Thanks
-Hareesh


 


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




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