Merge remote-tracking branch 'origin/master' into jetty-8

This commit is contained in:
Jan Bartel 2011-11-17 11:18:49 +11:00
commit cd41752b9c
3 changed files with 52 additions and 8 deletions

View File

@ -111,13 +111,19 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async
reset(); reset();
// TODO Is this required? // TODO Is this still required?
if (!_generator.isPersistent() && !_endp.isOutputShutdown()) if (!_generator.isPersistent() && !_endp.isOutputShutdown())
{ {
LOG.warn("Safety net oshut!!!"); LOG.warn("Safety net oshut!!! IF YOU SEE THIS, PLEASE RAISE BUGZILLA");
_endp.shutdownOutput(); _endp.shutdownOutput();
} }
} }
else if (_request.getAsyncContinuation().isAsyncStarted())
{
// The request is suspended, so even though progress has been made, break the while loop
LOG.debug("suspended {}",this);
break;
}
} }
} }
} }

View File

@ -35,16 +35,16 @@ import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class AsyncContextTest public class LocalAsyncContextTest
{ {
protected Server _server = new Server(); protected Server _server = new Server();
protected SuspendHandler _handler = new SuspendHandler(); protected SuspendHandler _handler = new SuspendHandler();
protected LocalConnector _connector; protected Connector _connector;
@Before @Before
public void init() throws Exception public void init() throws Exception
{ {
_connector = new LocalConnector(); _connector = initConnector();
_server.setConnectors(new Connector[]{ _connector }); _server.setConnectors(new Connector[]{ _connector });
SessionHandler session = new SessionHandler(); SessionHandler session = new SessionHandler();
@ -54,6 +54,11 @@ public class AsyncContextTest
_server.start(); _server.start();
} }
protected Connector initConnector()
{
return new LocalConnector();
}
@After @After
public void destroy() throws Exception public void destroy() throws Exception
{ {
@ -178,14 +183,21 @@ public class AsyncContextTest
private synchronized String process(String content) throws Exception private synchronized String process(String content) throws Exception
{ {
String request = "GET / HTTP/1.1\r\n" + "Host: localhost\r\n"; String request = "GET / HTTP/1.1\r\n" +
"Host: localhost\r\n"+
"Connection: close\r\n";
if (content==null) if (content==null)
request+="\r\n"; request+="\r\n";
else else
request+="Content-Length: "+content.length()+"\r\n" + "\r\n" + content; request+="Content-Length: "+content.length()+"\r\n" +"\r\n" + content;
return _connector.getResponses(request); return getResponse(request);
}
protected String getResponse(String request) throws Exception
{
return ((LocalConnector)_connector).getResponses(request);
} }
private static class SuspendHandler extends HandlerWrapper private static class SuspendHandler extends HandlerWrapper

View File

@ -0,0 +1,26 @@
package org.eclipse.jetty.server;
import java.net.Socket;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.util.IO;
public class SelectChannelAsyncContextTest extends LocalAsyncContextTest
{
@Override
protected Connector initConnector()
{
return new SelectChannelConnector();
}
@Override
protected String getResponse(String request) throws Exception
{
SelectChannelConnector connector = (SelectChannelConnector)_connector;
Socket socket = new Socket((String)null,connector.getLocalPort());
socket.getOutputStream().write(request.getBytes("UTF-8"));
return IO.toString(socket.getInputStream());
}
}