aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/android/volley/toolbox/HttpHeaderParserTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/android/volley/toolbox/HttpHeaderParserTest.java')
-rw-r--r--src/test/java/com/android/volley/toolbox/HttpHeaderParserTest.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/java/com/android/volley/toolbox/HttpHeaderParserTest.java b/src/test/java/com/android/volley/toolbox/HttpHeaderParserTest.java
index b8c4847..ae8257a 100644
--- a/src/test/java/com/android/volley/toolbox/HttpHeaderParserTest.java
+++ b/src/test/java/com/android/volley/toolbox/HttpHeaderParserTest.java
@@ -177,6 +177,10 @@ public class HttpHeaderParserTest {
headers.put("Content-Type", "text/plain; charset=utf-8");
assertEquals("utf-8", HttpHeaderParser.parseCharset(headers));
+ // Charset specified, ignore default charset
+ headers.put("Content-Type", "text/plain; charset=utf-8");
+ assertEquals("utf-8", HttpHeaderParser.parseCharset(headers, "ISO-8859-1"));
+
// Extra whitespace
headers.put("Content-Type", "text/plain; charset=utf-8 ");
assertEquals("utf-8", HttpHeaderParser.parseCharset(headers));
@@ -189,6 +193,10 @@ public class HttpHeaderParserTest {
headers.clear();
assertEquals("ISO-8859-1", HttpHeaderParser.parseCharset(headers));
+ // No Content-Type header, use default charset
+ headers.clear();
+ assertEquals("utf-8", HttpHeaderParser.parseCharset(headers, "utf-8"));
+
// Empty value
headers.put("Content-Type", "text/plain; charset=");
assertEquals("ISO-8859-1", HttpHeaderParser.parseCharset(headers));
@@ -197,6 +205,10 @@ public class HttpHeaderParserTest {
headers.put("Content-Type", "text/plain");
assertEquals("ISO-8859-1", HttpHeaderParser.parseCharset(headers));
+ // None charset specified, use default charset
+ headers.put("Content-Type", "application/json");
+ assertEquals("utf-8", HttpHeaderParser.parseCharset(headers, "utf-8"));
+
// None specified, extra semicolon
headers.put("Content-Type", "text/plain;");
assertEquals("ISO-8859-1", HttpHeaderParser.parseCharset(headers));