Support double-quoted in HttpHeaders::getValuesAsList
This commit introduces support for double-quoted HTTP header values in HttpHeaders::getValuesAsList, as described in RFC 9110 section 5.5. Closes gh-29785
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -713,4 +713,19 @@ public class HttpHeadersTests {
|
||||
assertThat(headers2).isEqualTo(headers1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getValuesAsList() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Foo", "Bar");
|
||||
headers.add("Foo", "Baz, Qux");
|
||||
headers.add("Quux", "\t\"Corge\", \"Grault\"");
|
||||
headers.add("Garply", " Waldo \"Fred\\!\", \"\tPlugh, Xyzzy! \"");
|
||||
headers.add("Example-Dates", "\"Sat, 04 May 1996\", \"Wed, 14 Sep 2005\"");
|
||||
|
||||
assertThat(headers.getValuesAsList("Foo")).containsExactly("Bar", "Baz", "Qux");
|
||||
assertThat(headers.getValuesAsList("Quux")).containsExactly("Corge", "Grault");
|
||||
assertThat(headers.getValuesAsList("Garply")).containsExactly("Waldo \"Fred\\!\"", "\tPlugh, Xyzzy! ");
|
||||
assertThat(headers.getValuesAsList("Example-Dates")).containsExactly("Sat, 04 May 1996", "Wed, 14 Sep 2005");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user