Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2013-09-05 03:19:12 +0000
committerGreg Wilkins2013-09-05 03:19:12 +0000
commita3f66333858269daf03679e6251c6f89c811f523 (patch)
treec7a8ce83b739bd6075b626416c95ee351af3dea7
parent4663fa4992f46b2a7f8c5cc052c97658bd9145b2 (diff)
parentce098c67deb25b2bf19a81413405f22ed12722d6 (diff)
downloadorg.eclipse.jetty.project-a3f66333858269daf03679e6251c6f89c811f523.tar.gz
org.eclipse.jetty.project-a3f66333858269daf03679e6251c6f89c811f523.tar.xz
org.eclipse.jetty.project-a3f66333858269daf03679e6251c6f89c811f523.zip
Merge remote-tracking branch 'origin/master' into jetty-9.1
Conflicts: jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java30
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java68
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java38
3 files changed, 109 insertions, 27 deletions
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java b/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java
index 8d68725277..698973ed50 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java
@@ -71,11 +71,14 @@ public class DumpHandler extends AbstractHandler
if (!isStarted())
return;
+ StringBuilder read = null;
if (request.getParameter("read")!=null)
{
+ read=new StringBuilder();
+ int len=Integer.parseInt(request.getParameter("read"));
Reader in = request.getReader();
- for (int i=Integer.parseInt(request.getParameter("read"));i-->0;)
- in.read();
+ for (int i=len;i-->0;)
+ read.append((char)in.read());
}
if (request.getParameter("ISE")!=null)
@@ -190,16 +193,23 @@ public class DumpHandler extends AbstractHandler
writer.write("</pre>\n<h3>Content:</h3>\n<pre>");
- char[] content= new char[4096];
- int len;
- try{
- Reader in=request.getReader();
- while((len=in.read(content))>=0)
- writer.write(new String(content,0,len));
+ if (read!=null)
+ {
+ writer.write(read.toString());
}
- catch(IOException e)
+ else
{
- writer.write(e.toString());
+ char[] content= new char[4096];
+ int len;
+ try{
+ Reader in=request.getReader();
+ while((len=in.read(content))>=0)
+ writer.write(new String(content,0,len));
+ }
+ catch(IOException e)
+ {
+ writer.write(e.toString());
+ }
}
writer.write("</pre>\n");
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 031832f903..6476fde3c4 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
@@ -68,6 +68,7 @@ public class HttpConnectionTest
http.getHttpConfiguration().setResponseHeaderSize(1024);
connector = new LocalConnector(server,http,null);
+ connector.setIdleTimeout(500);
server.addConnector(connector);
server.setHandler(new DumpHandler());
server.start();
@@ -385,6 +386,73 @@ public class HttpConnectionTest
}
@Test
+ public void testUnconsumed() throws Exception
+ {
+ String response=null;
+ String requests=null;
+ int offset=0;
+
+ offset=0;
+ requests=
+ "GET /R1?read=4 HTTP/1.1\n"+
+ "Host: localhost\n"+
+ "Transfer-Encoding: chunked\n"+
+ "Content-Type: text/plain; charset=utf-8\n"+
+ "\015\012"+
+ "5;\015\012"+
+ "12345\015\012"+
+ "5;\015\012"+
+ "67890\015\012"+
+ "0;\015\012\015\012"+
+ "GET /R2 HTTP/1.1\n"+
+ "Host: localhost\n"+
+ "Content-Type: text/plain; charset=utf-8\n"+
+ "Content-Length: 10\n"+
+ "Connection: close\n"+
+ "\n"+
+ "abcdefghij\n";
+
+ response=connector.getResponses(requests);
+
+ offset = checkContains(response,offset,"HTTP/1.1 200");
+ offset = checkContains(response,offset,"pathInfo=/R1");
+ offset = checkContains(response,offset,"1234");
+ checkNotContained(response,offset,"56789");
+ offset = checkContains(response,offset,"HTTP/1.1 200");
+ offset = checkContains(response,offset,"pathInfo=/R2");
+ offset = checkContains(response,offset,"encoding=UTF-8");
+ offset = checkContains(response,offset,"abcdefghij");
+ }
+
+ @Test
+ public void testUnconsumedTimeout() throws Exception
+ {
+ String response=null;
+ String requests=null;
+ int offset=0;
+
+ offset=0;
+ requests=
+ "GET /R1?read=4 HTTP/1.1\n"+
+ "Host: localhost\n"+
+ "Transfer-Encoding: chunked\n"+
+ "Content-Type: text/plain; charset=utf-8\n"+
+ "\015\012"+
+ "5;\015\012"+
+ "12345\015\012";
+
+ long start=System.currentTimeMillis();
+ response=connector.getResponses(requests,2000,TimeUnit.MILLISECONDS);
+ if ((System.currentTimeMillis()-start)>=2000)
+ Assert.fail();
+
+ offset = checkContains(response,offset,"HTTP/1.1 200");
+ offset = checkContains(response,offset,"pathInfo=/R1");
+ offset = checkContains(response,offset,"1234");
+ checkNotContained(response,offset,"56789");
+ }
+
+ @Test
public void testUnconsumedErrorRead() throws Exception
{
String response=null;
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
index 3a03ad2171..dcff963e3c 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
@@ -197,7 +197,14 @@ public class ServletHandler extends ScopedHandler
{
for (int i=_filters.length; i-->0;)
{
- try { _filters[i].stop(); }catch(Exception e){LOG.warn(Log.EXCEPTION,e);}
+ try
+ {
+ _filters[i].stop();
+ }
+ catch(Exception e)
+ {
+ LOG.warn(Log.EXCEPTION,e);
+ }
if (_filters[i].getSource() != Source.EMBEDDED)
{
//remove all of the mappings that were for non-embedded filters
@@ -234,7 +241,14 @@ public class ServletHandler extends ScopedHandler
{
for (int i=_servlets.length; i-->0;)
{
- try { _servlets[i].stop(); }catch(Exception e){LOG.warn(Log.EXCEPTION,e);}
+ try
+ {
+ _servlets[i].stop();
+ }
+ catch(Exception e)
+ {
+ LOG.warn(Log.EXCEPTION,e);
+ }
if (_servlets[i].getSource() != Source.EMBEDDED)
{
@@ -525,35 +539,25 @@ public class ServletHandler extends ScopedHandler
// unwrap cause
Throwable th=e;
- if (th instanceof UnavailableException)
- {
- LOG.debug(th);
- }
- else if (th instanceof ServletException)
+ if (th instanceof ServletException)
{
if (th instanceof QuietServletException)
{
- LOG.debug(th);
LOG.warn(th.toString());
+ LOG.debug(th);
}
else
LOG.warn(th);
}
- // handle or log exception
else if (th instanceof EofException)
- throw (EofException)th;
- else if (LOG.isDebugEnabled())
{
- LOG.warn(request.getRequestURI(), th);
- LOG.debug(request.toString());
- }
- else if (th instanceof IOException || th instanceof UnavailableException)
- {
- LOG.debug(request.getRequestURI(),th);
+ throw (EofException)th;
}
else
{
LOG.warn(request.getRequestURI(),th);
+ if (LOG.isDebugEnabled())
+ LOG.debug(request.toString());
}
if (!response.isCommitted())

Back to the top