From cbc3ac01f244f34d25d3e88e74e4bbf3d9dbff76 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 18 Sep 2024 17:42:21 +0200 Subject: [PATCH] #11841 add reproducer using jetty client Signed-off-by: Ludovic Orban --- .../ee10/proxy/AsyncMiddleManServletTest.java | 31 ++++++++++++++++--- .../ee9/proxy/AsyncMiddleManServletTest.java | 26 ++++++++++++++-- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServletTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServletTest.java index c1218587ab0..b32b99487ad 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServletTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServletTest.java @@ -61,6 +61,7 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; import org.eclipse.jetty.client.Request; import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.http.HttpHeader; @@ -79,6 +80,7 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.Utf8StringBuilder; import org.eclipse.jetty.util.ajax.JSON; +import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -163,11 +165,32 @@ public class AsyncMiddleManServletTest } @AfterEach - public void dispose() throws Exception + public void dispose() { - client.stop(); - proxy.stop(); - server.stop(); + LifeCycle.stop(client); + LifeCycle.stop(proxy); + LifeCycle.stop(server); + } + + @Test + public void testExpect100WithBody() throws Exception + { + startServer(new EchoHttpServlet()); + startProxy(new AsyncMiddleManServlet()); + startClient(); + + for (int i = 0; i < 100; i++) + { + String body = Character.toString('a' + (i % 26)); // only use 'a' to 'z' + ContentResponse response = client.newRequest("localhost", serverConnector.getLocalPort()) + .path("/" + body) + .headers(h -> h.put(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE)) + .timeout(5, TimeUnit.SECONDS) + .body(new StringRequestContent(body)) + .send(); + assertEquals(200, response.getStatus()); + assertEquals(body, response.getContentAsString()); + } } @Test diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServletTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServletTest.java index 064ac668745..433e59a41f2 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServletTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServletTest.java @@ -61,6 +61,7 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; import org.eclipse.jetty.client.Request; import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.http.HttpHeader; @@ -163,11 +164,32 @@ public class AsyncMiddleManServletTest } @AfterEach - public void dispose() throws Exception + public void dispose() { LifeCycle.stop(client); LifeCycle.stop(proxy); - LifeCycle.stop(proxy); + LifeCycle.stop(server); + } + + @Test + public void testExpect100WithBody() throws Exception + { + startServer(new EchoHttpServlet()); + startProxy(new AsyncMiddleManServlet()); + startClient(); + + for (int i = 0; i < 100; i++) + { + String body = Character.toString('a' + (i % 26)); // only use 'a' to 'z' + ContentResponse response = client.newRequest("localhost", serverConnector.getLocalPort()) + .path("/" + body) + .headers(h -> h.put(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE)) + .timeout(5, TimeUnit.SECONDS) + .body(new StringRequestContent(body)) + .send(); + assertEquals(200, response.getStatus()); + assertEquals(body, response.getContentAsString()); + } } @Test