diff --git a/core/src/main/java/org/nanohttpd/protocols/http/NanoHTTPD.java b/core/src/main/java/org/nanohttpd/protocols/http/NanoHTTPD.java index 42c21514..90e1747a 100644 --- a/core/src/main/java/org/nanohttpd/protocols/http/NanoHTTPD.java +++ b/core/src/main/java/org/nanohttpd/protocols/http/NanoHTTPD.java @@ -478,7 +478,7 @@ protected static Map> decodeParameters(String queryString) public static String decodePercent(String str) { String decoded = null; try { - decoded = URLDecoder.decode(str, "UTF8"); + decoded = URLDecoder.decode(str, "UTF-8"); } catch (UnsupportedEncodingException ignored) { NanoHTTPD.LOG.log(Level.WARNING, "Encoding not supported, ignored", ignored); } diff --git a/core/src/main/java/org/nanohttpd/protocols/http/content/ContentType.java b/core/src/main/java/org/nanohttpd/protocols/http/content/ContentType.java index bafe18ed..6efb7f73 100644 --- a/core/src/main/java/org/nanohttpd/protocols/http/content/ContentType.java +++ b/core/src/main/java/org/nanohttpd/protocols/http/content/ContentType.java @@ -38,7 +38,9 @@ public class ContentType { - private static final String ASCII_ENCODING = "US-ASCII"; + public static final String ASCII_ENCODING = "US-ASCII"; + + public static final String UTF8_ENCODING = "UTF-8"; private static final String MULTIPART_FORM_DATA_HEADER = "multipart/form-data"; @@ -69,7 +71,7 @@ public ContentType(String contentTypeHeader) { encoding = getDetailFromContentHeader(contentTypeHeader, CHARSET_PATTERN, null, 2); } else { contentType = ""; - encoding = "UTF-8"; + encoding = UTF8_ENCODING; } if (MULTIPART_FORM_DATA_HEADER.equalsIgnoreCase(contentType)) { boundary = getDetailFromContentHeader(contentTypeHeader, BOUNDARY_PATTERN, null, 2); @@ -92,7 +94,7 @@ public String getContentType() { } public String getEncoding() { - return encoding == null ? ASCII_ENCODING : encoding; + return encoding == null ? UTF8_ENCODING : encoding; } public String getBoundary() {