From 96c4c1ee7f1876a2c1a73d4e55e2befa93b5eb57 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 16 Sep 2009 01:37:26 +0000 Subject: [PATCH] JETTY-1112 Response fails if header exceeds buffer size git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@907 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 5 +- .../eclipse/jetty/server/HttpConnection.java | 2 + .../jetty/server/HttpConnectionTest.java | 56 +++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 93cf16e15ee..fbd86740722 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -6,8 +6,9 @@ jetty-7.0.1-SNAPSHOT + 289027 deobfuscate HttpClient SSL passwords jetty-7.0.0.RC6-SNAPSHOT - + JETTY-936 274251 Improved servlet matching and optimized' + + JETTY-719 Document state machine of jetty http client + JETTY-780 CNFE during startup of webapp with spring-context >= 2.5.1 + + JETTY-936 274251 Improved servlet matching and optimized' + JETTY-1080 modify previous fix to work on windows + JETTY-1084 HEAD command not setting content-type in response under certain circumstances + JETTY-1086 Use UncheckedPrintWriter @@ -18,6 +19,7 @@ jetty-7.0.0.RC6-SNAPSHOT + JETTY-1101 Updated servlet3 continuation constructor + JETTY-1105 Custom error pages aren't working + JETTY-1108 SSL EOF detection + + JETTY-1112 Response fails if header exceeds buffer size + 280723 Add non blocking statistics handler + 282543 HttpClient SSL buffer size fix + 283357 org.eclipse.jetty.server.HttpConnectionTest exceptions @@ -29,7 +31,6 @@ jetty-7.0.0.RC6-SNAPSHOT + 289146 formalize reload policy functionality + 289156 jetty-client: no longer throw runtime exception for bad authn details + 288182 PUT request fails during retry - + JETTY-719 Document state machine of jetty http client + 289221 HttpExchange does not timeout when using blocking connector jetty-6.1.20 27 August 2009 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 48f4ec88182..5b7c6924efe 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 @@ -668,6 +668,7 @@ public class HttpConnection implements Connection _generator.reset(true); _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null); _generator.completeHeader(_responseFields,HttpGenerator.LAST); + _generator.complete(); throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500); } @@ -699,6 +700,7 @@ public class HttpConnection implements Connection _generator.reset(true); _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null); _generator.completeHeader(_responseFields,HttpGenerator.LAST); + _generator.complete(); throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500); } } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java index 45ff097935c..6ce43ce6092 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java @@ -19,6 +19,16 @@ */ package org.eclipse.jetty.server; +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.http.HttpHeaders; +import org.eclipse.jetty.http.MimeTypes; + import junit.framework.TestCase; /** @@ -288,6 +298,52 @@ public class HttpConnectionTest extends TestCase } } + + + public void testOversizedResponse () + throws Exception + { + String str = "thisisastringthatshouldreachover1kbytes"; + for (int i=0;i<400;i++) + str+="xxxxxxxxxxxx"; + final String longstr = str; + String response = null; + server.stop(); + server.setHandler(new DumpHandler() + { + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException + { + baseRequest.setHandled(true); + response.setHeader(HttpHeaders.CONTENT_TYPE,MimeTypes.TEXT_HTML); + response.setHeader("LongStr", longstr); + PrintWriter writer = response.getWriter(); + writer.write("

FOO

"); + writer.flush(); + writer.close(); + } + }); + server.start(); + + try + { + int offset = 0; + + response = connector.getResponses("GET / HTTP/1.1\n"+ + "Host: localhost\n" + + "\015\012" + ); + + offset = checkContains(response, offset, "HTTP/1.1 500"); + } + catch(Exception e) + { + e.printStackTrace(); + if(response != null) + System.err.println(response); + fail("Exception"); + } + } + public void testAsterisk() {