Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x

This commit is contained in:
Greg Wilkins 2016-08-10 16:27:22 +10:00
commit 08b9ac6b27
2 changed files with 18 additions and 1 deletions

View File

@ -282,7 +282,9 @@ public class BufferedResponseHandler extends HandlerWrapper
protected void commit(Queue<ByteBuffer> buffers, Callback callback)
{
// If only 1 buffer
if (_buffers.size()==1)
if (_buffers.size()==0)
getNextInterceptor().write(BufferUtil.EMPTY_BUFFER,true,callback);
else if (_buffers.size()==1)
// just flush it with the last callback
getNextInterceptor().write(_buffers.remove(),true,callback);
else

View File

@ -203,6 +203,21 @@ public class BufferedResponseHandlerTest
assertThat(response,not(containsString("Write: 1")));
assertThat(response,containsString("Written: true"));
}
@Test
public void testFlushEmpty() throws Exception
{
_test._writes=1;
_test._flush=true;
_test._close=false;
_test._content = new byte[0];
String response = _local.getResponse("GET /ctx/include/path HTTP/1.1\r\nHost: localhost\r\n\r\n");
assertThat(response,containsString(" 200 OK"));
assertThat(response,containsString("Content-Length: "));
assertThat(response,containsString("Write: 0"));
assertThat(response,not(containsString("Write: 1")));
assertThat(response,containsString("Written: true"));
}
public static class TestHandler extends AbstractHandler
{