From 83f503b86f8f56b013886c2ce0868580d9fe037b Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 16 Aug 2016 17:40:18 +1000 Subject: [PATCH] Issue #845 data rate limits test for variable idle time --- .../jetty/server/ConnectorTimeoutTest.java | 38 +++++++++++++++++++ .../server/ServerConnectorTimeoutTest.java | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java index 65453e9b916..c37c2ba5ccb 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java @@ -78,6 +78,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture { _httpConfiguration.setBlockingTimeout(-1L); _httpConfiguration.setMinRequestDataRate(-1); + _httpConfiguration.setIdleTimeout(-1); } } @@ -882,6 +883,43 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture Assert.assertThat(response,containsString("=========")); } + + @Test(timeout=60000) + public void testHttpIdleTime() throws Exception + { + _httpConfiguration.setIdleTimeout(500); + configureServer(new EchoHandler()); + Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort()); + client.setSoTimeout(10000); + + Assert.assertFalse(client.isClosed()); + + OutputStream os=client.getOutputStream(); + InputStream is=client.getInputStream(); + + try (StacklessLogging scope = new StacklessLogging(HttpChannel.class)) + { + os.write(( + "POST /echo HTTP/1.0\r\n"+ + "host: "+_serverURI.getHost()+":"+_serverURI.getPort()+"\r\n"+ + "content-type: text/plain; charset=utf-8\r\n"+ + "content-length: 20\r\n"+ + "\r\n").getBytes("utf-8")); + os.flush(); + + os.write("123456789\n".getBytes("utf-8")); + os.flush(); + Thread.sleep(1000); + os.write("=========\n".getBytes("utf-8")); + os.flush(); + + String response =IO.toString(is); + Assert.assertThat(response,containsString(" 500 ")); + Assert.assertThat(response,containsString("/500 ms")); + Assert.assertThat(response,Matchers.not(containsString("========="))); + } + } + diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTimeoutTest.java index bfc0b16edb4..e10cb8d5de1 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTimeoutTest.java @@ -38,7 +38,7 @@ public class ServerConnectorTimeoutTest extends ConnectorTimeoutTest public void init() throws Exception { ServerConnector connector = new ServerConnector(_server,1,1); - connector.setIdleTimeout(MAX_IDLE_TIME); // 250 msec max idle + connector.setIdleTimeout(MAX_IDLE_TIME); startServer(connector); }