373037 jetty.server.Response.setContentLength(int) should not close a Writer when length=0
This commit is contained in:
parent
0c4450dc5d
commit
35a0386df0
|
@ -783,7 +783,7 @@ public class Response implements HttpServletResponse
|
|||
if (isCommitted() || _connection.isIncluding())
|
||||
return;
|
||||
_connection._generator.setContentLength(len);
|
||||
if (len>=0)
|
||||
if (len>0)
|
||||
{
|
||||
_connection.getResponseFields().putLongField(HttpHeaders.CONTENT_LENGTH, len);
|
||||
if (_connection._generator.isAllContentWritten())
|
||||
|
|
|
@ -439,6 +439,20 @@ public class ResponseTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZeroContent () throws Exception
|
||||
{
|
||||
Response response = new Response (new TestHttpConnection(connector, new ByteArrayEndPoint(), connector.getServer()));
|
||||
PrintWriter writer = response.getWriter();
|
||||
response.setContentLength(0);
|
||||
assertTrue(!response.isCommitted());
|
||||
assertTrue(!writer.checkError());
|
||||
writer.print("");
|
||||
assertTrue(!writer.checkError());
|
||||
assertTrue(response.isCommitted());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHead() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue