avoid double request handling when suspended
This commit is contained in:
parent
e48570bd5e
commit
97b48a5b93
|
@ -111,14 +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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,16 +31,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();
|
||||||
|
@ -49,6 +49,11 @@ public class AsyncContextTest
|
||||||
_server.setHandler(session);
|
_server.setHandler(session);
|
||||||
_server.start();
|
_server.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Connector initConnector()
|
||||||
|
{
|
||||||
|
return new LocalConnector();
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void destroy() throws Exception
|
public void destroy() throws Exception
|
||||||
|
@ -129,14 +134,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
|
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue