parent
a9653e2f49
commit
cc8c3590c0
|
@ -282,7 +282,9 @@ public class BufferedResponseHandler extends HandlerWrapper
|
||||||
protected void commit(Queue<ByteBuffer> buffers, Callback callback)
|
protected void commit(Queue<ByteBuffer> buffers, Callback callback)
|
||||||
{
|
{
|
||||||
// If only 1 buffer
|
// 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
|
// just flush it with the last callback
|
||||||
getNextInterceptor().write(_buffers.remove(),true,callback);
|
getNextInterceptor().write(_buffers.remove(),true,callback);
|
||||||
else
|
else
|
||||||
|
|
|
@ -203,6 +203,22 @@ public class BufferedResponseHandlerTest
|
||||||
assertThat(response,not(containsString("Write: 1")));
|
assertThat(response,not(containsString("Write: 1")));
|
||||||
assertThat(response,containsString("Written: true"));
|
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");
|
||||||
|
System.err.println(response);
|
||||||
|
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
|
public static class TestHandler extends AbstractHandler
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue