diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/RequestTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/RequestTest.java index 40f4f0f..47c6010 100644 --- a/okhttp-tests/src/test/java/com/squareup/okhttp/RequestTest.java +++ b/okhttp-tests/src/test/java/com/squareup/okhttp/RequestTest.java @@ -188,8 +188,11 @@ public final class RequestTest { assertForbiddenHeader("\t"); assertForbiddenHeader("\u001f"); assertForbiddenHeader("\u007f"); - assertForbiddenHeader("\u0080"); - assertForbiddenHeader("\ud83c\udf69"); + + // ANDROID-BEGIN Workaround for http://b/28867041 + // assertForbiddenHeader("\u0080"); + // assertForbiddenHeader("\ud83c\udf69"); + // ANDROID-END } private void assertForbiddenHeader(String s) { diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/URLConnectionTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/URLConnectionTest.java index d638deb..d930ec8 100644 --- a/okhttp-tests/src/test/java/com/squareup/okhttp/URLConnectionTest.java +++ b/okhttp-tests/src/test/java/com/squareup/okhttp/URLConnectionTest.java @@ -2839,11 +2839,14 @@ private void reusedConnectionFailsWithPost(TransferKind transferKind, int reques fail(); } catch (IllegalArgumentException expected) { } - try { - connection.addRequestProperty("Name", "\u2615\ufe0f"); - fail(); - } catch (IllegalArgumentException expected) { - } + + // ANDROID-BEGIN Disabled for http://b/28867041 + // try { + // connection.addRequestProperty("Name", "\u2615\ufe0f"); + // fail(); + // } catch (IllegalArgumentException expected) { + // } + // ANDROID-END } @Test public void responseHeaderParsingIsLenient() throws Exception { diff --git a/okhttp/src/main/java/com/squareup/okhttp/Headers.java b/okhttp/src/main/java/com/squareup/okhttp/Headers.java index dad91bf..d5b4cef 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/Headers.java +++ b/okhttp/src/main/java/com/squareup/okhttp/Headers.java @@ -304,7 +304,12 @@ private void checkNameAndValue(String name, String value) { for (int i = 0, length = value.length(); i < length; i++) { char c = value.charAt(i); - if (c <= '\u001f' || c >= '\u007f') { + // ANDROID-BEGIN + // http://b/28867041 - keep things working for apps that rely on Android's (out of spec) + // UTF-8 header encoding behavior. + // if (c <= '\u001f' || c >= '\u007f') { + if (c <= '\u001f' || c == '\u007f') { + // ANDROID-END throw new IllegalArgumentException(String.format( "Unexpected char %#04x at %d in header value: %s", (int) c, i, value)); }