Proposal to fix issue #3768 (3.10)

Motivations:
When using HttpPostRequestEncoder and trying to set an attribute if a
charset is defined, currenlty implicit Charset.toStrng() is used, given
wrong format.
As in Android for UTF-16 = "com.ibm.icu4jni.charset.CharsetICU[UTF-16]".

Modifications:
Each time charset is used to be printed as its name, charset.name() is
used to get the canonical name.

Result:
Now get "UTF-16" instead.
(3.10 version)
This commit is contained in:
Frederic Bregier 2015-05-11 00:07:04 +02:00 committed by Norman Maurer
parent ef95fbf6bb
commit d0c81604b6
3 changed files with 5 additions and 4 deletions

View File

@ -129,7 +129,7 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" + getName() +
"\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" +
HttpHeaders.Names.CONTENT_TYPE + ": " + contentType +
(charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset + "\r\n" : "\r\n") +
(charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset.name() + "\r\n" : "\r\n") +
HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" +
"Completed: " + isCompleted() +
"\r\nIsInMemory: " + isInMemory() + "\r\nRealFile: " +

View File

@ -492,7 +492,7 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " +
HttpPostBodyUtil.DEFAULT_TEXT_CONTENT_TYPE + "; " +
HttpHeaders.Values.CHARSET + '='
+ localcharset + "\r\n");
+ localcharset.name() + "\r\n");
}
// CRLF between body header and data
internal.addValue("\r\n");
@ -644,7 +644,8 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
internal.addValue("\r\n" + HttpHeaders.Names.CONTENT_TRANSFER_ENCODING + ": "
+ HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value() + "\r\n\r\n");
} else if (fileUpload.getCharset() != null) {
internal.addValue("; " + HttpHeaders.Values.CHARSET + '=' + fileUpload.getCharset() + "\r\n\r\n");
internal.addValue("; " + HttpHeaders.Values.CHARSET + '='
+ fileUpload.getCharset().name() + "\r\n\r\n");
} else {
internal.addValue("\r\n\r\n");
}

View File

@ -123,7 +123,7 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" + getName() +
"\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" +
HttpHeaders.Names.CONTENT_TYPE + ": " + contentType +
(charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset + "\r\n" : "\r\n") +
(charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset.name() + "\r\n" : "\r\n") +
HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" +
"Completed: " + isCompleted() +
"\r\nIsInMemory: " + isInMemory();