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 bb5f9fe078
commit 61dced3dcd
3 changed files with 4 additions and 4 deletions

View File

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

View File

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

View File

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