Skip to content

Commit

Permalink
[JENKINS-73381] Downloading tar.gz artifacts in Firefox is broken (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Jul 1, 2024
1 parent 7dd2180 commit f15766d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/resources/winstone/mime.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/winstone/LauncherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String, String> 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<byte[]> 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);
}
}
Binary file added src/testwebapp/lipsum.tar.gz
Binary file not shown.

0 comments on commit f15766d

Please sign in to comment.