diff --git a/src/main/resources/winstone/mime.properties b/src/main/resources/winstone/mime.properties index e5768c1b..76b659ab 100644 --- a/src/main/resources/winstone/mime.properties +++ b/src/main/resources/winstone/mime.properties @@ -279,7 +279,8 @@ gtm=application/vnd.groove-tool-message gtw=model/vnd.gtw gv=text/vnd.graphviz gxt=application/vnd.geonext -gz=application/x-gzip +gz=application/gzip +gzip=application/gzip h261=video/h261 h263=video/h263 h264=video/h264 @@ -765,6 +766,7 @@ sxw=application/vnd.sun.xml.writer taglet=application/vnd.mynfc tao=application/vnd.tao.intent-module-archive tar=application/x-tar +tar.gz=application/gzip tcap=application/vnd.3gpp2.tcap tcl=application/x-tcl teacher=application/vnd.smart.teacher @@ -776,7 +778,7 @@ texinfo=application/x-texinfo text=text/plain tfi=application/thraud+xml tfm=application/x-tex-tfm -tgz=application/x-gzip +tgz=application/x-gtar thmx=application/vnd.ms-officetheme tiff=image/tiff tif=image/tiff diff --git a/src/test/java/winstone/LauncherTest.java b/src/test/java/winstone/LauncherTest.java index b4e99d14..577b26ce 100644 --- a/src/test/java/winstone/LauncherTest.java +++ b/src/test/java/winstone/LauncherTest.java @@ -17,6 +17,7 @@ import java.util.zip.GZIPInputStream; import org.eclipse.jetty.server.ServerConnector; import org.junit.Test; +import org.jvnet.hudson.test.Issue; /** * @author Kohsuke Kawaguchi @@ -97,4 +98,27 @@ public void mimeType() throws Exception { assertEquals("text/xxx", response.headers().firstValue("Content-Type").get()); assertEquals("Hello", response.body()); } + + @Issue("JENKINS-60409") + @Test + public void doubleGzip() throws Exception { + Map args = new HashMap<>(); + args.put("warfile", "target/test-classes/test.war"); + args.put("prefix", "/"); + args.put("httpPort", "0"); + winstone = new Launcher(args); + int port = ((ServerConnector) winstone.server.getConnectors()[0]).getLocalPort(); + HttpRequest request = HttpRequest.newBuilder(new URI("http://127.0.0.2:" + port + "/lipsum.tar.gz")) + .header("Accept-Encoding", "gzip") + .GET() + .build(); + HttpResponse response = + HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofByteArray()); + assertEquals(HttpURLConnection.HTTP_OK, response.statusCode()); + assertEquals( + "application/gzip", + response.headers().firstValue("Content-Type").orElseThrow()); + assertFalse(response.headers().firstValue("Content-Encoding").isPresent()); + assertEquals(1345, response.body().length); + } } diff --git a/src/testwebapp/lipsum.tar.gz b/src/testwebapp/lipsum.tar.gz new file mode 100644 index 00000000..8d7ecfd0 Binary files /dev/null and b/src/testwebapp/lipsum.tar.gz differ