406390 Close if at END and content remaining
This commit is contained in:
parent
fbf89e75aa
commit
a5c701c237
|
@ -652,6 +652,9 @@ public class HttpParser
|
||||||
case CACHE_CONTROL:
|
case CACHE_CONTROL:
|
||||||
case USER_AGENT:
|
case USER_AGENT:
|
||||||
add_to_connection_trie=_connectionFields!=null && _field==null;
|
add_to_connection_trie=_connectionFields!=null && _field==null;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_to_connection_trie && !_connectionFields.isFull() && _header!=null && _valueString!=null)
|
if (add_to_connection_trie && !_connectionFields.isFull() && _header!=null && _valueString!=null)
|
||||||
|
@ -1089,6 +1092,8 @@ public class HttpParser
|
||||||
BufferUtil.clear(buffer);
|
BufferUtil.clear(buffer);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
default: break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request/response line
|
// Request/response line
|
||||||
|
@ -1262,6 +1267,9 @@ public class HttpParser
|
||||||
BufferUtil.clear(buffer);
|
BufferUtil.clear(buffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,8 +207,29 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
||||||
// Can the parser progress (even with an empty buffer)
|
// Can the parser progress (even with an empty buffer)
|
||||||
boolean call_channel=_parser.parseNext(_requestBuffer==null?BufferUtil.EMPTY_BUFFER:_requestBuffer);
|
boolean call_channel=_parser.parseNext(_requestBuffer==null?BufferUtil.EMPTY_BUFFER:_requestBuffer);
|
||||||
|
|
||||||
// If there is a request buffer, we are re-entering here
|
// Parse the buffer
|
||||||
if (!call_channel && BufferUtil.isEmpty(_requestBuffer))
|
if (call_channel)
|
||||||
|
{
|
||||||
|
// Parse as much content as there is available before calling the channel
|
||||||
|
// this is both efficient (may queue many chunks), will correctly set available for 100 continues
|
||||||
|
// and will drive the parser to completion if all content is available.
|
||||||
|
while (_parser.inContentState())
|
||||||
|
{
|
||||||
|
if (!_parser.parseNext(_requestBuffer==null?BufferUtil.EMPTY_BUFFER:_requestBuffer))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The parser returned true, which indicates the channel is ready to handle a request.
|
||||||
|
// Call the channel and this will either handle the request/response to completion OR,
|
||||||
|
// if the request suspends, the request/response will be incomplete so the outer loop will exit.
|
||||||
|
|
||||||
|
_channel.run();
|
||||||
|
|
||||||
|
// Return if suspended or upgraded
|
||||||
|
if (_channel.getState().isSuspended() || getEndPoint().getConnection()!=this)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (BufferUtil.isEmpty(_requestBuffer))
|
||||||
{
|
{
|
||||||
if (_requestBuffer == null)
|
if (_requestBuffer == null)
|
||||||
_requestBuffer = _bufferPool.acquire(getInputBufferSize(), REQUEST_BUFFER_DIRECT);
|
_requestBuffer = _bufferPool.acquire(getInputBufferSize(), REQUEST_BUFFER_DIRECT);
|
||||||
|
@ -242,33 +263,15 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
||||||
releaseRequestBuffer();
|
releaseRequestBuffer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse what we have read
|
|
||||||
call_channel=_parser.parseNext(_requestBuffer);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// Parse the buffer
|
|
||||||
if (call_channel)
|
|
||||||
{
|
{
|
||||||
// Parse as much content as there is available before calling the channel
|
// TODO work out how we can get here and a better way to handle it
|
||||||
// this is both efficient (may queue many chunks), will correctly set available for 100 continues
|
LOG.warn("Unexpected state: "+this+ " "+_channel+" "+_channel.getRequest());
|
||||||
// and will drive the parser to completion if all content is available.
|
getEndPoint().close();
|
||||||
while (_parser.inContentState())
|
return;
|
||||||
{
|
}
|
||||||
if (!_parser.parseNext(_requestBuffer==null?BufferUtil.EMPTY_BUFFER:_requestBuffer))
|
System.err.println(_channel.getRequest());
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The parser returned true, which indicates the channel is ready to handle a request.
|
|
||||||
// Call the channel and this will either handle the request/response to completion OR,
|
|
||||||
// if the request suspends, the request/response will be incomplete so the outer loop will exit.
|
|
||||||
|
|
||||||
_channel.run();
|
|
||||||
|
|
||||||
// Return if suspended or upgraded
|
|
||||||
if (_channel.getState().isSuspended() || getEndPoint().getConnection()!=this)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (EofException e)
|
catch (EofException e)
|
||||||
|
|
Loading…
Reference in New Issue