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 Scott Yeadon <sc...@anu.edu.au> on 2009/11/12 05:47:58 UTC

MultipartEntity and HttpMultipart

Hi,

Using HTTP components 4.0 I wanted to create a POST request using the 
multipart/mixed content type. However the MultipartEntity does not allow 
the contentType to be set and is hardcoded to multipart/form-data. 
Looking through the API it looks as though the HttpMultipart class (and 
its associated classes) are available to address the various multipart 
media types, however it appears to be incompatible with HttpPost addPart 
method as HttpMultipart does not implement the HttpEntity interface. I 
could not locate an obvious class used for request handling for 
"HttpMultipart"-based requests. It appears the simplest means to POST a 
request with multipart/mixed contentType is to create a new entity class 
implementing HttpEntity (e.g. MultipartMixedEntity) - is that correct or 
are there other means of doing this with the 4.0 API?

Also, what is the relation between these sets of entity classes - the 
HttpEntity implentations appear in the "entity" package and the others 
appear in the "mime" package? Is there some sort of de-lineation or 
usage rules for these classes I should be aware of?

Thanks.

Scott.

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


Re: MultipartEntity and HttpMultipart

Posted by Christine Karman <ch...@christine.nl>.
Oleg Kalnichevski wrote:
> On Thu, 2009-11-12 at 15:47 +1100, Scott Yeadon wrote:
>   
>> "HttpMultipart"-based requests. It appears the simplest means to POST a 
>> request with multipart/mixed contentType is to create a new entity class 
>> implementing HttpEntity (e.g. MultipartMixedEntity) - is that correct or 
>> are there other means of doing this with the 4.0 API?
>>
>>     
>
> You will be better off just overriding the #generateContentTypre method
> of the MultipartEntity class.
>   
I agree with Oleg, I have done as he says, I have extended the 
MultipartMime class and overridden one or two methods. I remember there 
were some issues with setting and getting the content type, I don't know 
if that has been fixed or not.

Christine
>
>   
>> Also, what is the relation between these sets of entity classes - the 
>> HttpEntity implentations appear in the "entity" package and the others 
>> appear in the "mime" package? Is there some sort of de-lineation or 
>> usage rules for these classes I should be aware of?
>>
>>     
>
> HttpMime is somewhat special because it is not fully API stable due to
> its dependency on Mime4j, which is still considered API unstable.  
>
> Hope this answers your question.
>
> Oleg
>
>   
>> Thanks.
>>
>> Scott.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>     
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>   


-- 
dagdag is just a two-character rotation of byebye.


Re: MultipartEntity and HttpMultipart

Posted by Scott Yeadon <sc...@anu.edu.au>.
Hi Oleg,

Yes, that answers my question, thanks.

Scott.

Oleg Kalnichevski wrote:
> On Thu, 2009-11-12 at 15:47 +1100, Scott Yeadon wrote:
>   
>> Hi,
>>
>> Using HTTP components 4.0 I wanted to create a POST request using the 
>> multipart/mixed content type. However the MultipartEntity does not allow 
>> the contentType to be set and is hardcoded to multipart/form-data. 
>> Looking through the API it looks as though the HttpMultipart class (and 
>> its associated classes) are available to address the various multipart 
>> media types, however it appears to be incompatible with HttpPost addPart 
>> method as HttpMultipart does not implement the HttpEntity interface. I 
>> could not locate an obvious class used for request handling for 
>> "HttpMultipart"-based requests. It appears the simplest means to POST a 
>> request with multipart/mixed contentType is to create a new entity class 
>> implementing HttpEntity (e.g. MultipartMixedEntity) - is that correct or 
>> are there other means of doing this with the 4.0 API?
>>
>>     
>
> You will be better off just overriding the #generateContentTypre method
> of the MultipartEntity class.
>
>
>   
>> Also, what is the relation between these sets of entity classes - the 
>> HttpEntity implentations appear in the "entity" package and the others 
>> appear in the "mime" package? Is there some sort of de-lineation or 
>> usage rules for these classes I should be aware of?
>>
>>     
>
> HttpMime is somewhat special because it is not fully API stable due to
> its dependency on Mime4j, which is still considered API unstable.  
>
> Hope this answers your question.
>
> Oleg
>
>   
>> Thanks.
>>
>> Scott.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>     
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
>   


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


Re: MultipartEntity and HttpMultipart

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2009-11-12 at 15:47 +1100, Scott Yeadon wrote:
> Hi,
> 
> Using HTTP components 4.0 I wanted to create a POST request using the 
> multipart/mixed content type. However the MultipartEntity does not allow 
> the contentType to be set and is hardcoded to multipart/form-data. 
> Looking through the API it looks as though the HttpMultipart class (and 
> its associated classes) are available to address the various multipart 
> media types, however it appears to be incompatible with HttpPost addPart 
> method as HttpMultipart does not implement the HttpEntity interface. I 
> could not locate an obvious class used for request handling for 
> "HttpMultipart"-based requests. It appears the simplest means to POST a 
> request with multipart/mixed contentType is to create a new entity class 
> implementing HttpEntity (e.g. MultipartMixedEntity) - is that correct or 
> are there other means of doing this with the 4.0 API?
> 

You will be better off just overriding the #generateContentTypre method
of the MultipartEntity class.


> Also, what is the relation between these sets of entity classes - the 
> HttpEntity implentations appear in the "entity" package and the others 
> appear in the "mime" package? Is there some sort of de-lineation or 
> usage rules for these classes I should be aware of?
> 

HttpMime is somewhat special because it is not fully API stable due to
its dependency on Mime4j, which is still considered API unstable.  

Hope this answers your question.

Oleg

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



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