From dd2f1166ae9bc569bf5899c4fdbb181b8218922d Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 3 May 2010 20:19:36 +0000 Subject: [PATCH] 306782 Close connection when expected 100 continues is not sent git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1660 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 1 + .../org/eclipse/jetty/server/HttpConnection.java | 4 ++++ .../java/org/eclipse/jetty/server/RFC2616Test.java | 14 ++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/VERSION.txt b/VERSION.txt index 976d827ebd6..0450a5842ca 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -2,6 +2,7 @@ jetty-7.1.0.RC1-SNAPSHOT + 296650 JETTY-1198 reset idle timeout on request body chunks + 291448 SessionManager has isCheckingRemoteSessionIdEncoding + 297104 HTTP CONNECT does not work correct with SSL destinations + + 306782 Close connection when expected 100 continues is not sent + 308848 Update test suite to JUnit4 - Module jetty-ajp + 308861 Update test suite to JUnit4 - Module jetty-security + 308868 Update test suite to JUnit4 - Module jetty-websocket diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java index 1764fc83635..3b9c503e79e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java @@ -685,6 +685,10 @@ public class HttpConnection implements Connection _generator.setResponse(_response.getStatus(), _response.getReason()); try { + // If the client was expecting 100 continues, but we sent something + // else, then we need to close the connection + if (_expect100Continue && _response.getStatus()!=100) + _generator.setPersistent(false); _generator.completeHeader(_responseFields, last); } catch(IOException io) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/RFC2616Test.java b/jetty-server/src/test/java/org/eclipse/jetty/server/RFC2616Test.java index 10cda0874fe..0c7cc67eb57 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/RFC2616Test.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/RFC2616Test.java @@ -391,6 +391,20 @@ public class RFC2616Test extends TestCase offset=checkContains(response,offset,"654321","8.2.3 expect 100")+1; */ + // Expect 100 not sent + ((StdErrLog)Log.getLog()).setHideStacks(true); + offset=0; + + response=connector.getResponses("GET /R1?error=401 HTTP/1.1\n"+ + "Host: localhost\n"+ + "Expect: 100-continue\n"+ + "Content-Type: text/plain\n"+ + "Content-Length: 8\n"+ + "\n",true); + checkNotContained(response,offset,"HTTP/1.1 100","8.2.3 expect 100"); + offset=checkContains(response,offset,"HTTP/1.1 401 ","8.2.3 expect 100")+1; + offset=checkContains(response,offset,"Connection: close","8.2.3 expect 100")+1; + ((StdErrLog)Log.getLog()).setHideStacks(false); } catch (Exception e)