Skip to content

Commit

Permalink
jetty#7863 Include value of first accept-encoding header where multip…
Browse files Browse the repository at this point in the history
…le accept-encoding headers are given. (jetty#7864)

Signed-off-by: markslater <mark.slater@mail.com>
  • Loading branch information
markslater committed Apr 11, 2022
1 parent 80f4251 commit 8bcb842
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 @@ -1917,6 +1917,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 8bcb842

Please sign in to comment.