Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2014-12-31 10:48:23 +0000
committerGreg Wilkins2014-12-31 10:48:23 +0000
commit5f2a7fdfceeb13cb904d299613b16a6ad88bab57 (patch)
tree95a8e530f46cbb11f77278e3e0ebfea8eff4fced
parent191286970a98c05b45e3e92093ba6d5b019fdb27 (diff)
downloadorg.eclipse.jetty.project-5f2a7fdfceeb13cb904d299613b16a6ad88bab57.tar.gz
org.eclipse.jetty.project-5f2a7fdfceeb13cb904d299613b16a6ad88bab57.tar.xz
org.eclipse.jetty.project-5f2a7fdfceeb13cb904d299613b16a6ad88bab57.zip
fixed http client respond before consumed test.
The server now is a bit lazier if the handler has not consumed content. It will not block to consume and gives up and closes the connection instead.
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
index c3cd2ecad8..5c59060ee2 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.client;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpCookie;
import java.net.URI;
@@ -43,6 +44,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
+
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
@@ -520,7 +522,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
@Test
public void test_ExchangeIsComplete_OnlyWhenBothRequestAndResponseAreComplete() throws Exception
{
- start(new EmptyServerHandler());
+ start(new RespondThenConsumeHandler());
// Prepare a big file to upload
Path targetTestsDir = testdir.getEmptyDir().toPath();
@@ -577,6 +579,23 @@ public class HttpClientTest extends AbstractHttpClientServerTest
Files.delete(file);
}
+
+ private static class RespondThenConsumeHandler extends AbstractHandler
+ {
+ @Override
+ public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException
+ {
+ baseRequest.setHandled(true);
+ response.setContentLength(0);
+ response.setStatus(200);
+ response.flushBuffer();
+
+ InputStream in = request.getInputStream();
+ while(in.read()>=0);
+ }
+
+ }
@Test
public void test_ExchangeIsComplete_WhenRequestFailsMidway_WithResponse() throws Exception

Back to the top