jetty-9 fixed some test fails after refactor

This commit is contained in:
Greg Wilkins 2012-08-23 08:39:05 +10:00
parent ab5c8ee508
commit 74e632cd34
5 changed files with 21 additions and 8 deletions

View File

@ -1053,8 +1053,7 @@ public class HttpParser
LOG.warn("badMessage: "+e.toString()+" for "+_handler);
LOG.debug(e);
_handler.badMessage(400, e.toString());
BufferUtil.clear(buffer);
badMessage(buffer,e.toString());
return true;
}
}

View File

@ -634,7 +634,15 @@ public class HttpChannel implements HttpParser.RequestHandler
{
if (status < 400 || status > 599)
status = HttpStatus.BAD_REQUEST_400;
_response.sendError(status, null, null);
try
{
commitResponse(new ResponseInfo(HttpVersion.HTTP_1_1,new HttpFields(),0,status,reason,false),null,true);
}
catch (IOException e)
{
LOG.warn(e);
}
}
// TODO: port the logic present in this method

View File

@ -274,8 +274,8 @@ public class HttpConnection extends AbstractConnection implements Runnable
{
_parser.reset();
_parser.close();
_generator.setPersistent(false);
_channel.getResponse().sendError(Response.SC_REQUEST_ENTITY_TOO_LARGE, null, null);
// TODO: close the connection !
break;
}
else

View File

@ -51,6 +51,7 @@ public class HttpTransportOverHttp implements HttpTransport
@Override
public void commit(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean complete) throws IOException
{
// TODO This is blocking! One of the important use-cases is to be able to write large static content without a thread
generate(info, content, complete);
// TODO: Trick only needed by the current HttpGenerator, that always require a ResponseInfo object
if (!complete)
@ -101,12 +102,17 @@ public class HttpTransportOverHttp implements HttpTransport
{
if (info.isHead())
{
write(header);
BufferUtil.clear(content);
if (BufferUtil.hasContent(header))
blockingWrite(header);
}
else if (BufferUtil.hasContent(header))
{
blockingWrite(header, content);
}
else
{
write(header == null ? BufferUtil.EMPTY_BUFFER : header, content);
blockingWrite(content);
}
continue;
}
@ -131,7 +137,7 @@ public class HttpTransportOverHttp implements HttpTransport
}
}
private void write(ByteBuffer... bytes) throws IOException
private void blockingWrite(ByteBuffer... bytes) throws IOException
{
try
{

View File

@ -184,7 +184,7 @@ public class HttpConnectionTest
@Test
public void testBad() throws Exception
{
HttpParser.LOG.info("badMessage: 3 bad messages expected ...");
Log.getLogger(HttpParser.class).info("badMessage: 3 bad messages expected ...");
String response;
response=connector.getResponses("GET http://localhost:EXPECTED_NUMBER_FORMAT_EXCEPTION/ HTTP/1.1\n"+