388502 handle earlyEOF with 500

This commit is contained in:
Greg Wilkins 2012-08-31 19:00:42 +10:00
parent da82238d6b
commit c3844a43c9
4 changed files with 13 additions and 4 deletions

View File

@ -497,6 +497,8 @@ public abstract class AbstractHttpConnection extends AbstractConnection
LOG.debug(e); LOG.debug(e);
error=true; error=true;
_request.setHandled(true); _request.setHandled(true);
if (!_response.isCommitted())
_generator.sendError(500, null, null, true);
} }
catch (RuntimeIOException e) catch (RuntimeIOException e)
{ {
@ -549,9 +551,8 @@ public abstract class AbstractHttpConnection extends AbstractConnection
{ {
if (error) if (error)
{ {
_generator.setPersistent(false);
_generator.flushBuffer();
_endp.shutdownOutput(); _endp.shutdownOutput();
_generator.setPersistent(false);
if (!_generator.isComplete()) if (!_generator.isComplete())
_response.complete(); _response.complete();
} }

View File

@ -226,7 +226,12 @@ public class SocketConnector extends AbstractConnector
{ {
int l = super.fill(buffer); int l = super.fill(buffer);
if (l<0) if (l<0)
close(); {
if (!isInputShutdown())
shutdownInput();
if (isOutputShutdown())
close();
}
return l; return l;
} }

View File

@ -194,7 +194,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
String response = readResponse(client); String response = readResponse(client);
client.close(); client.close();
// assertThat("response contains 500", response.contains(" 500 "), is(true)); //TODO: check with gregw, assertThat("response contains 500", response, Matchers.containsString(" 500 "));
assertThat("The 4th byte (-1) has not been passed to the handler", fourBytesRead.get(), is(false)); assertThat("The 4th byte (-1) has not been passed to the handler", fourBytesRead.get(), is(false));
assertThat("EofException has been caught", earlyEOFException.get(), is(true)); assertThat("EofException has been caught", earlyEOFException.get(), is(true));
} }

View File

@ -19,6 +19,8 @@
package org.eclipse.jetty.server; package org.eclipse.jetty.server;
import org.eclipse.jetty.server.bio.SocketConnector; import org.eclipse.jetty.server.bio.SocketConnector;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
/** /**
* HttpServer Tester. * HttpServer Tester.
@ -30,4 +32,5 @@ public class SocketServerTest extends HttpServerTestBase
{ {
startServer(new SocketConnector()); startServer(new SocketConnector());
} }
} }