diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt index c142cdcbd72e..65c110e2649f 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt @@ -1223,15 +1223,30 @@ class NavigationDelegateTest : BaseSessionTest() { .getString("Header2"), equalTo("Value1, Value2")) } + @Ignore("HttpBin incorrectly filters empty field values") + @Test fun loadUriHeaderEmptyFieldValue() { + val headers = mapOf( + "ValueLess1" to "", + "ValueLess2" to null) + + sessionRule.session.loadUri("$TEST_ENDPOINT/anything", headers) + sessionRule.session.waitForPageStop() + + val content = sessionRule.session.evaluateJS("document.body.children[0].innerHTML") as String + val body = JSONObject(content) + val headersJSON = body.getJSONObject("headers") + + MatcherAssert.assertThat("Header with no field value should be included", + headersJSON.has("ValueLess1")) + MatcherAssert.assertThat("Header with no field value should be included", + headersJSON.has("ValueLess2")) + } + @Test fun loadUriHeaderBadOverrides() { val headers = mapOf( null to "BadNull", "Connection" to "BadConnection", - "Host" to "BadHost", - "ValueLess1" to "", - "ValueLess2" to null, - "ValueLess3" to " ", - "ValueLess4" to "\t") + "Host" to "BadHost") sessionRule.session.loadUri("$TEST_ENDPOINT/anything", headers) sessionRule.session.waitForPageStop() @@ -1254,16 +1269,6 @@ class NavigationDelegateTest : BaseSessionTest() { MatcherAssert.assertThat("Headers should not match", headersJSON .getString("Host"), not("BadHost")) - // As per RFC7230 all request headers must have a field value (Except Host, which we filter) - // RFC7230 makes RFC2616 obsolete but 2616 allowed empty field values. - MatcherAssert.assertThat("Header with no field value should not be included", - !headersJSON.has("ValueLess1")) - MatcherAssert.assertThat("Header with no field value should not be included", - !headersJSON.has("ValueLess2")) - MatcherAssert.assertThat("Header with no field value should not be included", - !headersJSON.has("ValueLess3")) - MatcherAssert.assertThat("Header with no field value should not be included", - !headersJSON.has("ValueLess4")) } @Test(expected = GeckoResult.UncaughtException::class) diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java index b725b17d3a00..6883264999bc 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java @@ -1628,12 +1628,7 @@ public class GeckoSession implements Parcelable { if (key == null) continue; - String value = additionalHeaders.get(key); - - // As per RFC7230 headers must contain a field value - if (value != null && !value.equals("")) { - headers.add( String.format("%s:%s", key, additionalHeaders.get(key)) ); - } + headers.add( String.format("%s:%s", key, additionalHeaders.get(key)) ); } return headers; }