393075 1xx 204 and 304 ignore all headers suggesting content

This commit is contained in:
Greg Wilkins 2012-11-08 14:36:48 +11:00
parent e615504889
commit eaf65a2902
2 changed files with 16 additions and 8 deletions

View File

@ -525,7 +525,7 @@ public class HttpParser implements Parser
switch (ho)
{
case HttpHeaders.CONTENT_LENGTH_ORDINAL:
if (_contentLength != HttpTokens.CHUNKED_CONTENT && _responseStatus!=304 && _responseStatus!=204 && (_responseStatus<100 || _responseStatus>=200))
if (_contentLength != HttpTokens.CHUNKED_CONTENT )
{
try
{
@ -596,12 +596,17 @@ public class HttpParser implements Parser
}
_buffer.setMarkIndex(-1);
// now handle ch
if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
{
// work out the _content demarcation
if (_contentLength == HttpTokens.UNKNOWN_CONTENT)
// is it a response that cannot have a body?
if (_responseStatus > 0 && // response
(_responseStatus == 304 || // not-modified response
_responseStatus == 204 || // no-content response
_responseStatus < 200)) // 1xx response
_contentLength=HttpTokens.NO_CONTENT; // ignore any other headers set
// else if we don't know framing
else if (_contentLength == HttpTokens.UNKNOWN_CONTENT)
{
if (_responseStatus == 0 // request
|| _responseStatus == 304 // not-modified response

View File

@ -44,14 +44,15 @@ public class TomcatServerQuirksTest
* @throws IOException
*/
@Test
@Ignore("Bug with Transfer-Encoding")
public void testTomcat7_0_32_WithTransferEncoding() throws Exception {
public void testTomcat7_0_32_WithTransferEncoding() throws Exception
{
DummyServer server = new DummyServer();
int bufferSize = 512;
QueuedThreadPool threadPool = new QueuedThreadPool();
WebSocketClientFactory factory = new WebSocketClientFactory(threadPool, new ZeroMaskGen(), bufferSize);
try {
try
{
server.start();
// Setup Client Factory
@ -113,7 +114,9 @@ public class TomcatServerQuirksTest
socket.flush();
Assert.assertTrue(dataLatch.await(1000, TimeUnit.SECONDS));
} finally {
}
finally
{
factory.stop();
threadPool.stop();
server.stop();