[ https://issues.apache.org/jira/browse/HTTPCLIENT-2360?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17931434#comment-17931434 ]
ASF subversion and git services commented on HTTPCLIENT-2360: ------------------------------------------------------------- Commit fc3b11e98bed28a47fe000bf308c3c027d34df83 in httpcomponents-client's branch refs/heads/master from Arturo Bernal [ https://gitbox.apache.org/repos/asf?p=httpcomponents-client.git;h=fc3b11e98 ] HTTPCLIENT-2360 - Enhance filename encoding in multipart/form-data per RFC 6266/5987 (#618) - Modified FormBodyPartBuilder to support HttpMultipartMode, adding filename* with UTF-8 encoding for non-ISO-8859-1 filenames in STRICT/EXTENDED modes, skipping it in LEGACY mode. - Updated HttpRFC7578Multipart to use mode for filename encoding: percent-encode in EXTENDED, ISO-8859-1 in STRICT/LEGACY, and always encode filename* per RFC 5987. - Adjusted MultipartEntityBuilder to propagate mode to FormBodyPartBuilder, ensuring consistent behavior across the pipeline. - Fixed tests to align with mode-specific expectations, maintaining LEGACY mode’s raw UTF-8 filename behavior. > rfc6266 support in MIME multipart > --------------------------------- > > Key: HTTPCLIENT-2360 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2360 > Project: HttpComponents HttpClient > Issue Type: Improvement > Components: HttpClient (classic) > Affects Versions: 5.4.1 > Reporter: Hiran Chaudhuri > Priority: Minor > Labels: volunteers-wanted > Fix For: Stuck > > Attachments: TestHttpClient.zip > > Time Spent: 1h > Remaining Estimate: 0h > > The following code creates a bad HTTP request: > > {code:java} > File file = ... > FileBody fileBody = new FileBody(sourceFile); > MultipartEntityBuilder builder = MultipartEntityBuilder.create(); > builder.setMode(HttpMultipartMode.LEGACY); > builder.addPart("document", fileBody); > HttpEntity requestEntity = builder.build(); > URI endpoint = ... > HttpPost httpPost = new HttpPost(endpoint.toString()); > httpPost.setEntity(requestEntity); > httpClient.execute(httpPost, getHttpClientContext(), ...); {code} > The request contains the file and a {{Content-Disposition}} header. Inside > this header the filename is contained. So far so good. > > But as filesystems go international and support all kinds of characters, the > {{filename}} header needs to be encoded in ISO-8859-1 or rfc5987 applies. But > in reality HttpClient 5.4.1 uses UTF-8 encoding, which can break other > servers trying to parse the request. > I like to use this client a lot. Please enhance it to follow > https://www.rfc-editor.org/rfc/rfc6266#page-5 which allows to use UTF-8 > encoding in the {{filename*}} header. Or even better, HttpClient fills both > headers so the server can pick. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org