From f15766dd48820b94878c8f3d6f2062bce7212696 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Mon, 1 Jul 2024 12:26:29 -0700 Subject: [PATCH] [JENKINS-73381] Downloading `tar.gz` artifacts in Firefox is broken (#397) --- src/main/resources/winstone/mime.properties | 6 +++-- src/test/java/winstone/LauncherTest.java | 24 ++++++++++++++++++++ src/testwebapp/lipsum.tar.gz | Bin 0 -> 1345 bytes 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/testwebapp/lipsum.tar.gz 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 0000000000000000000000000000000000000000..8d7ecfd029aa61ac16f2795092eb79a28bcabf38 GIT binary patch literal 1345 zcmV-H1-|+piwFP!000001MODJj@w2M-1C0Ld;lTrdcB*o;amd5MuH%@x5$yy!EmUZ zhp?ZY>gGIX14&Ls;D8MXlE`^?GA-$!$Zx#=TmzVeQ{rJQ4!}eR^`T6DH z?(zN0(-VF^K4IMByT`|Ocjn>SrPL$GM8TN5BSm)qFz(;pf2Z;D66|bL1ZG;?5=`V| zXtrrEzZ*nq@ z&+_VKoxy}04L&1QOXh;H!3J6G_hf7~o{tyvnmL+l4j5UNGttgh8;rN3@r&1S2lI(C z7BplcUD1py~V)7WT%TZPNS=jbol8`N5Er5|Ad1*ztOyU{jz0 z8MqsJXk(@r>0mx*=V-=1-82V}F*g+HNp_-C;3EKc%kG*JCA&iSn(-DO0>Fk#LP6MW z;}chZgME(V)4Fj7r`g8 zBLKoCi?f)~b2d|EO{u(S_zFQ0pSSH3FPl~}RhVb&y{bv%0?7GhLm(&wS*beh>BJ)g z_MviClB6PavG1VOe23qVxAy!A< z7MIhN@c3f@KT8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