You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Victor Freire (JIRA)" <ji...@apache.org> on 2013/04/02 13:17:16 UTC

[jira] [Commented] (HTTPCLIENT-1332) Missing content-type MultipartEntity Request

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13619714#comment-13619714 ] 

Victor Freire commented on HTTPCLIENT-1332:
-------------------------------------------

Sorry about that, I hadn't looked the BROWSER_COMPATIBLE  flag up in the JavaDocs. 

It didn't cross my mind that some web servers would want the Content-Type to be omitted.

In my opinion, a warning when the content-type of a part was different than 'plain/text' and BROWSER_COMPATIBLE was being used would be nice to avoid this misunderstanding.

Thanks for the quick solution!
                
> Missing content-type MultipartEntity Request
> --------------------------------------------
>
>                 Key: HTTPCLIENT-1332
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1332
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpMime
>    Affects Versions: 4.2.3
>         Environment: OS: Windows 7 (Microsoft Windows [Version 6.1.7600])
> JDK: jdk1.7.0_13
> Libs:
> - httpclient-4.2.3.jar
> - httpcore-4.2.2.jar
> - httpmime-4.2.3.jar
>            Reporter: Victor Freire
>            Priority: Blocker
>              Labels: content-type, multipart, multipart/form-data
>
> *** Given the following code:
> HttpClient httpClient = new DefaultHttpClient();
> MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
> entity.addPart("metadata", new StringBody("{ \"number\": 4}", "application/json", Charset.forName("UTF-8")));
> HttpPost httpPost = new HttpPost("http://localhost:8080/");
> httpPost.setEntity(entity);
> httpClient.execute(httpPost);
> *** The request comes out without the requested content-type ("application/json") and cannot be interpreted by the application server. There should be a "Content-Type: application/json" right after Content-Disposition in the request body below.
> POST /boards/publish/123/images/an_image_field_key
> Host: localhost:8080
> Content-type: multipart/form-data; boundary=hRc10UDcwcHyZlNbQwa2NaN-Qq4FxhIq3VHUoKk0
> Content-length: 282
> Connection: Keep-Alive
> User-agent: Apache-HttpClient/4.2.3 (java 1.5)
> --hRc10UDcwcHyZlNbQwa2NaN-Qq4FxhIq3VHUoKk0
> Content-Disposition: form-data; name="metadata"
> {  "number": 4}
> --hRc10UDcwcHyZlNbQwa2NaN-Qq4FxhIq3VHUoKk0--

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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