diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java index 51140fbed8fe..efe2cd69a9c3 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java @@ -327,6 +327,7 @@ private List getPreferredEncodingOrder(HttpServletRequest request) if (headers.hasMoreElements()) { StringBuilder sb = new StringBuilder(key.length() * 2); + sb.append(key); do { sb.append(',').append(headers.nextElement()); diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java index 1e92abfd7ffe..18fd7d286b9c 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java @@ -1932,6 +1932,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