#7863 Include value of first accept-encoding header where multiple accept-encoding headers are given. (#7864)

Signed-off-by: markslater <mark.slater@mail.com>
This commit is contained in:
markslater 2022-04-11 16:09:18 +01:00 committed by Joakim Erdfelt
parent 0b05425aa5
commit 1f844e8d57
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
2 changed files with 11 additions and 0 deletions

View File

@ -339,6 +339,7 @@ public class ResourceService
if (headers.hasMoreElements())
{
StringBuilder sb = new StringBuilder(key.length() * 2);
sb.append(key);
do
{
sb.append(',').append(headers.nextElement());

View File

@ -1925,6 +1925,16 @@ public class DefaultServletTest
assertThat(response, containsHeaderValue(HttpHeader.CONTENT_ENCODING, "gzip"));
body = response.getContent();
assertThat(body, containsString("fake gzip"));
rawResponse = connector.getResponse("GET /context/data0.txt HTTP/1.0\r\nHost:localhost:8080\r\nAccept-Encoding:br\r\nAccept-Encoding:gzip, compress\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.OK_200));
assertThat(response, containsHeaderValue(HttpHeader.CONTENT_LENGTH, "11"));
assertThat(response, containsHeaderValue(HttpHeader.CONTENT_TYPE, "text/plain"));
assertThat(response, containsHeaderValue(HttpHeader.VARY, "Accept-Encoding"));
assertThat(response, containsHeaderValue(HttpHeader.CONTENT_ENCODING, "br"));
body = response.getContent();
assertThat(body, containsString("fake brotli"));
}
@Test