diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/BufferedResponseHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/BufferedResponseHandlerTest.java index a7b08b85067..efc2c26d46c 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/BufferedResponseHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/BufferedResponseHandlerTest.java @@ -18,8 +18,8 @@ import java.util.Arrays; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.io.Content; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.io.NullByteBufferPool; +import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.LocalConnector; diff --git a/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java index a1d48a5d055..a18addbbb8d 100644 --- a/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java +++ b/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java @@ -32,6 +32,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.stream.Collectors; import org.eclipse.jetty.start.Props.Prop; @@ -335,7 +336,7 @@ public class Main base.source); // 4) Active Module Resolution - List selectedModules = args.getSelectedModules(); + Set selectedModules = args.getSelectedModules(); List sortedSelectedModules = modules.getSortedNames(selectedModules); List unknownModules = new ArrayList<>(selectedModules); unknownModules.removeAll(sortedSelectedModules); diff --git a/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java b/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java index b0bc8e777a1..c8fab059a37 100644 --- a/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java +++ b/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java @@ -462,15 +462,6 @@ public class StartArgs return allModules; } - /** - * @deprecated use {@link #getSelectedModules()} instead - */ - @Deprecated - public List getEnabledModules() - { - return getSelectedModules(); - } - /** *

* The list of selected Modules to enable based on configuration @@ -484,7 +475,7 @@ public class StartArgs * @return the list of selected modules (by name) that the configuration has. * @see Modules#getEnabled() */ - public List getSelectedModules() + public Set getSelectedModules() { return this.modules; } diff --git a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/HugeResourceTest.java b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/HugeResourceTest.java index be9a20b9965..111ff32b6e3 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/HugeResourceTest.java +++ b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/HugeResourceTest.java @@ -102,7 +102,7 @@ public class HugeResourceTest makeStaticFile(staticBase.resolve("test-1g.dat"), GB); makeStaticFile(staticBase.resolve("test-4g.dat"), 4 * GB); - makeStaticFile(staticBase.resolve("test-10g.dat"), 10 * GB); + // makeStaticFile(staticBase.resolve("test-10g.dat"), 10 * GB); outputDir = MavenTestingUtils.getTargetTestingPath(HugeResourceTest.class.getSimpleName() + "-outputdir"); FS.ensureEmpty(outputDir); @@ -117,7 +117,7 @@ public class HugeResourceTest ret.add(Arguments.of("test-1g.dat", GB)); ret.add(Arguments.of("test-4g.dat", 4 * GB)); - ret.add(Arguments.of("test-10g.dat", 10 * GB)); + // ret.add(Arguments.of("test-10g.dat", 10 * GB)); return ret.stream(); } diff --git a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/HttpOutputTest.java b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/HttpOutputTest.java index 6aa4d11a2f2..1a3bed64106 100644 --- a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/HttpOutputTest.java +++ b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/HttpOutputTest.java @@ -31,9 +31,9 @@ import jakarta.servlet.ServletException; import jakarta.servlet.WriteListener; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.io.NullByteBufferPool; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.LocalConnector; -import org.eclipse.jetty.io.NullByteBufferPool; import org.eclipse.jetty.server.LocalConnector.LocalEndPoint; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.BufferUtil; diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/HugeResourceTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/HugeResourceTest.java index 308100cb4b5..159284bd95f 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/HugeResourceTest.java +++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/HugeResourceTest.java @@ -18,6 +18,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; +import java.net.URL; import java.nio.ByteBuffer; import java.nio.channels.SeekableByteChannel; import java.nio.file.FileStore; @@ -189,6 +190,7 @@ public class HugeResourceTest context.setBaseResource(new PathResource(staticBase)); context.addServlet(PostServlet.class, "/post"); + context.addServlet(ChunkedServlet.class, "/chunked/*"); String location = multipartTempDir.toString(); long maxFileSize = Long.MAX_VALUE; @@ -224,7 +226,7 @@ public class HugeResourceTest @ParameterizedTest @MethodSource("staticFiles") - public void testDownload(String filename, long expectedSize) throws Exception + public void testDownloadStatic(String filename, long expectedSize) throws Exception { URI destUri = server.getURI().resolve("/" + filename); InputStreamResponseListener responseListener = new InputStreamResponseListener(); @@ -251,7 +253,33 @@ public class HugeResourceTest @ParameterizedTest @MethodSource("staticFiles") - public void testHead(String filename, long expectedSize) throws Exception + public void testDownloadChunked(String filename, long expectedSize) throws Exception + { + URI destUri = server.getURI().resolve("/chunked/" + filename); + InputStreamResponseListener responseListener = new InputStreamResponseListener(); + + Request request = client.newRequest(destUri) + .method(HttpMethod.GET); + request.send(responseListener); + Response response = responseListener.get(5, TimeUnit.SECONDS); + + assertThat("HTTP Response Code", response.getStatus(), is(200)); + // dumpResponse(response); + + String transferEncoding = response.getHeaders().get(HttpHeader.TRANSFER_ENCODING); + assertThat("Http Response Header: \"Transfer-Encoding\"", transferEncoding, is("chunked")); + + try (ByteCountingOutputStream out = new ByteCountingOutputStream(); + InputStream in = responseListener.getInputStream()) + { + IO.copy(in, out); + assertThat("Downloaded Files Size: " + filename, out.getCount(), is(expectedSize)); + } + } + + @ParameterizedTest + @MethodSource("staticFiles") + public void testHeadStatic(String filename, long expectedSize) throws Exception { URI destUri = server.getURI().resolve("/" + filename); InputStreamResponseListener responseListener = new InputStreamResponseListener(); @@ -274,6 +302,30 @@ public class HugeResourceTest assertThat("Http Response Header: \"Content-Length: " + contentLength + "\"", contentLengthLong, is(expectedSize)); } + @ParameterizedTest + @MethodSource("staticFiles") + public void testHeadChunked(String filename, long expectedSize) throws Exception + { + URI destUri = server.getURI().resolve("/chunked/" + filename); + InputStreamResponseListener responseListener = new InputStreamResponseListener(); + + Request request = client.newRequest(destUri) + .method(HttpMethod.HEAD); + request.send(responseListener); + Response response = responseListener.get(5, TimeUnit.SECONDS); + + try (InputStream in = responseListener.getInputStream()) + { + assertThat(in.read(), is(-1)); + } + + assertThat("HTTP Response Code", response.getStatus(), is(200)); + // dumpResponse(response); + + String transferEncoding = response.getHeaders().get(HttpHeader.TRANSFER_ENCODING); + assertThat("Http Response Header: \"Transfer-Encoding\"", transferEncoding, is("chunked")); + } + @ParameterizedTest @MethodSource("staticFiles") public void testUpload(String filename, long expectedSize) throws Exception @@ -361,6 +413,22 @@ public class HugeResourceTest } } + public static class ChunkedServlet extends HttpServlet + { + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException + { + URL resource = req.getServletContext().getResource(req.getPathInfo()); + OutputStream output = resp.getOutputStream(); + try (InputStream input = resource.openStream()) + { + resp.setContentType("application/octet-stream"); + resp.flushBuffer(); + IO.copy(input, output); + } + } + } + public static class MultipartServlet extends HttpServlet { @Override