From 3a022b2cf9b6c6dd50d5bec79303f79b03986936 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Thu, 16 Dec 2010 23:59:08 +0000 Subject: [PATCH] HTTPCLIENT-1036 StringBody has incorrect default for characterset. git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1050239 13f79535-47bb-0310-9956-ffa450edef68 --- RELEASE_NOTES.txt | 3 +++ .../org/apache/http/entity/mime/content/StringBody.java | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 7a94c58a7..be4a0ef59 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,6 +1,9 @@ Changes since 4.1 BETA1 ----------------------- +* [HTTPCLIENT-1036] StringBody has incorrect default for characterset. (Default changed to US-ASCII) + Contributed by Sebastian Bazley + * [HTTPCLIENT-1033] HttpRoute.equals(Object o) is quite inefficient, as it does not take full advantage of shortcut logic Contributed by Sebastian Bazley diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java index 1bb69533b..fadca70da 100644 --- a/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java +++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java @@ -81,7 +81,7 @@ public class StringBody extends AbstractContentBody { * * @param text to be used for the body, not {@code null} * @param mimeType the mime type, may be {@code null} - * @param charset the character set, may be {@code null}, in which case the hosts default charset is used + * @param charset the character set, may be {@code null}, in which case the US-ASCII charset is used * @throws UnsupportedEncodingException * @throws IllegalArgumentException if the {@code text} parameter is null */ @@ -94,7 +94,7 @@ public class StringBody extends AbstractContentBody { throw new IllegalArgumentException("Text may not be null"); } if (charset == null) { - charset = Charset.defaultCharset(); + charset = Charset.forName("US-ASCII"); } this.content = text.getBytes(charset.name()); this.charset = charset; @@ -105,7 +105,7 @@ public class StringBody extends AbstractContentBody { * The mime type is set to "text/plain". * * @param text to be used for the body, not {@code null} - * @param charset the character set, may be {@code null}, in which case the hosts default charset is used + * @param charset the character set, may be {@code null}, in which case the US-ASCII charset is used * @throws UnsupportedEncodingException * @throws IllegalArgumentException if the {@code text} parameter is null */