зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1567549 - Removes incorrect empty field-value filter r=geckoview-reviewers,snorp
Removes incorrect empty field-value filter Differential Revision: https://phabricator.services.mozilla.com/D45569 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4dfb7c75f9
Коммит
4084340583
|
@ -1223,15 +1223,30 @@ class NavigationDelegateTest : BaseSessionTest() {
|
||||||
.getString("Header2"), equalTo("Value1, Value2"))
|
.getString("Header2"), equalTo("Value1, Value2"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore("HttpBin incorrectly filters empty field values")
|
||||||
|
@Test fun loadUriHeaderEmptyFieldValue() {
|
||||||
|
val headers = mapOf<String?, String?>(
|
||||||
|
"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() {
|
@Test fun loadUriHeaderBadOverrides() {
|
||||||
val headers = mapOf<String?, String?>(
|
val headers = mapOf<String?, String?>(
|
||||||
null to "BadNull",
|
null to "BadNull",
|
||||||
"Connection" to "BadConnection",
|
"Connection" to "BadConnection",
|
||||||
"Host" to "BadHost",
|
"Host" to "BadHost")
|
||||||
"ValueLess1" to "",
|
|
||||||
"ValueLess2" to null,
|
|
||||||
"ValueLess3" to " ",
|
|
||||||
"ValueLess4" to "\t")
|
|
||||||
|
|
||||||
sessionRule.session.loadUri("$TEST_ENDPOINT/anything", headers)
|
sessionRule.session.loadUri("$TEST_ENDPOINT/anything", headers)
|
||||||
sessionRule.session.waitForPageStop()
|
sessionRule.session.waitForPageStop()
|
||||||
|
@ -1254,16 +1269,6 @@ class NavigationDelegateTest : BaseSessionTest() {
|
||||||
MatcherAssert.assertThat("Headers should not match", headersJSON
|
MatcherAssert.assertThat("Headers should not match", headersJSON
|
||||||
.getString("Host"), not("BadHost"))
|
.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)
|
@Test(expected = GeckoResult.UncaughtException::class)
|
||||||
|
|
|
@ -1628,13 +1628,8 @@ public class GeckoSession implements Parcelable {
|
||||||
if (key == null)
|
if (key == null)
|
||||||
continue;
|
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;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче