306782 Do not skip content if 100 not sent, but content available
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1417 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
b12bdbc06e
commit
c4e8eb1a29
|
@ -312,7 +312,7 @@ public abstract class AbstractHttpExchangeCancelTest extends TestCase
|
|||
{
|
||||
HttpClient httpClient = getHttpClient();
|
||||
httpClient.stop();
|
||||
httpClient.setTimeout(2000);
|
||||
httpClient.setTimeout(1000);
|
||||
httpClient.start();
|
||||
|
||||
TestHttpExchange exchange = new TestHttpExchange();
|
||||
|
@ -395,6 +395,7 @@ public abstract class AbstractHttpExchangeCancelTest extends TestCase
|
|||
@Override
|
||||
protected void onException(Throwable ex)
|
||||
{
|
||||
// ex.printStackTrace();
|
||||
this.failed = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -638,20 +638,28 @@ public class HttpConnection implements Connection
|
|||
|
||||
if (_expect100Continue)
|
||||
{
|
||||
// We didn't send a 100 continues, but if there is
|
||||
// content, then the client obviously ignored us and
|
||||
// we need to read it. If there is no content, then
|
||||
// We didn't send a response, but if there is
|
||||
// content, then the client obviously ignored 100 mechanism
|
||||
// and we need to read it. If there is no content, then
|
||||
// we should not expect any to arrive and should skip
|
||||
// it
|
||||
_expect100Continue = false;
|
||||
if (_parser instanceof HttpParser)
|
||||
if (_parser instanceof HttpParser )
|
||||
{
|
||||
HttpParser parser=(HttpParser)_parser;
|
||||
|
||||
// is there already content?
|
||||
if ((parser.getHeaderBuffer()==null || parser.getHeaderBuffer().length()<2) &&
|
||||
(parser.getBodyBuffer()==null || parser.getBodyBuffer().length()<1))
|
||||
// No - so let's not expect it.
|
||||
// if response is committed, then _expect100Continue was not cleared
|
||||
// in commitResponse(boolean) or completeResponse(), so any data that
|
||||
// is available must have arrived after the commit and should be a new
|
||||
// request. So we should skip any unexpected content for this request.
|
||||
|
||||
if (_generator.isCommitted())
|
||||
((HttpParser)_parser).setState(HttpParser.STATE_END);
|
||||
|
||||
// else if there is not already content, then let's not expect any.
|
||||
else if (
|
||||
((parser.getHeaderBuffer()==null || parser.getHeaderBuffer().length()<2) &&
|
||||
(parser.getBodyBuffer()==null || parser.getBodyBuffer().length()<1)))
|
||||
((HttpParser)_parser).setState(HttpParser.STATE_END);
|
||||
}
|
||||
}
|
||||
|
@ -685,6 +693,20 @@ public class HttpConnection implements Connection
|
|||
{
|
||||
if (!_generator.isCommitted())
|
||||
{
|
||||
if (_expect100Continue && _parser instanceof HttpParser)
|
||||
{
|
||||
// We didn't send a 100 continues, so if there is
|
||||
// content, then the client obviously ignored the spec
|
||||
// and sent the body anyway. So we can cancel the
|
||||
// expected status.
|
||||
HttpParser parser=(HttpParser)_parser;
|
||||
|
||||
// is there already content?
|
||||
if ((parser.getHeaderBuffer()!=null && parser.getHeaderBuffer().length()>=2) ||
|
||||
(parser.getBodyBuffer()!=null && parser.getBodyBuffer().length()>0))
|
||||
_expect100Continue = false; // 100 mechanism has been ignored.
|
||||
}
|
||||
|
||||
_generator.setResponse(_response.getStatus(), _response.getReason());
|
||||
try
|
||||
{
|
||||
|
@ -716,6 +738,20 @@ public class HttpConnection implements Connection
|
|||
{
|
||||
if (!_generator.isCommitted())
|
||||
{
|
||||
if (_expect100Continue && _parser instanceof HttpParser)
|
||||
{
|
||||
// We didn't send a 100 continues, so if there is
|
||||
// content, then the client obviously ignored the spec
|
||||
// and sent the body anyway. So we can cancel the
|
||||
// expected status.
|
||||
HttpParser parser=(HttpParser)_parser;
|
||||
|
||||
// is there already content?
|
||||
if ((parser.getHeaderBuffer()!=null && parser.getHeaderBuffer().length()>=2) ||
|
||||
(parser.getBodyBuffer()!=null && parser.getBodyBuffer().length()>0))
|
||||
_expect100Continue = false; // 100 mechanism has been ignored.
|
||||
}
|
||||
|
||||
_generator.setResponse(_response.getStatus(), _response.getReason());
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue