Skip to content

Commit

Permalink
#7863 Include value of first accept-encoding header where multiple ac…
Browse files Browse the repository at this point in the history
…cept-encoding headers are given.

Signed-off-by: markslater <[email protected]>
  • Loading branch information
markslater committed Apr 8, 2022
1 parent 1369ef9 commit f17beca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ private List<String> getPreferredEncodingOrder(HttpServletRequest request)
if (headers.hasMoreElements())
{
StringBuilder sb = new StringBuilder(key.length() * 2);
sb.append(key);
do
{
sb.append(',').append(headers.nextElement());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,16 @@ public void testDefaultBrotliOverGzip() throws Exception
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
Expand Down

0 comments on commit f17beca

Please sign in to comment.