Merged branch 'jetty-9.3.x' into 'jetty-9.4.x'.
This commit is contained in:
commit
7923032582
|
@ -271,6 +271,12 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
|
|||
return !proceed || async;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messageComplete()
|
||||
{
|
||||
|
|
|
@ -284,6 +284,12 @@ public class ResponseContentParser extends StreamContentParser
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messageComplete()
|
||||
{
|
||||
|
|
|
@ -175,6 +175,7 @@ public class ServerFCGIConnection extends AbstractConnection
|
|||
LOG.debug("Request {} end on {}", request, channel);
|
||||
if (channel != null)
|
||||
{
|
||||
channel.onContentComplete();
|
||||
channel.onRequestComplete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -588,6 +588,24 @@ public class HttpParser
|
|||
_length=-1;
|
||||
return s;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
private boolean handleHeaderContentMessage()
|
||||
{
|
||||
boolean handle_header = _handler.headerComplete();
|
||||
_headerComplete = true;
|
||||
boolean handle_content = _handler.contentComplete();
|
||||
boolean handle_message = _handler.messageComplete();
|
||||
return handle_header || handle_content || handle_message;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
private boolean handleContentMessage()
|
||||
{
|
||||
boolean handle_content = _handler.contentComplete();
|
||||
boolean handle_message = _handler.messageComplete();
|
||||
return handle_content || handle_message;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/* Parse a request or response line
|
||||
|
@ -736,10 +754,7 @@ public class HttpParser
|
|||
handle=_requestHandler.startRequest(_methodString,_uri.toString(), HttpVersion.HTTP_0_9);
|
||||
setState(State.END);
|
||||
BufferUtil.clear(buffer);
|
||||
handle=_handler.headerComplete()||handle;
|
||||
_headerComplete=true;
|
||||
handle=_handler.messageComplete()||handle;
|
||||
return handle;
|
||||
handle= handleHeaderContentMessage() || handle;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -807,10 +822,7 @@ public class HttpParser
|
|||
handle=_requestHandler.startRequest(_methodString,_uri.toString(), HttpVersion.HTTP_0_9);
|
||||
setState(State.END);
|
||||
BufferUtil.clear(buffer);
|
||||
handle=_handler.headerComplete()||handle;
|
||||
_headerComplete=true;
|
||||
handle=_handler.messageComplete()||handle;
|
||||
return handle;
|
||||
handle= handleHeaderContentMessage() || handle;
|
||||
}
|
||||
}
|
||||
else if (ch<0)
|
||||
|
@ -1100,10 +1112,7 @@ public class HttpParser
|
|||
case NO_CONTENT:
|
||||
{
|
||||
setState(State.END);
|
||||
boolean handle=_handler.headerComplete();
|
||||
_headerComplete=true;
|
||||
handle=_handler.messageComplete()||handle;
|
||||
return handle;
|
||||
return handleHeaderContentMessage();
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
@ -1368,7 +1377,7 @@ public class HttpParser
|
|||
if (_responseStatus>0 && _headResponse)
|
||||
{
|
||||
setState(State.END);
|
||||
return _handler.messageComplete();
|
||||
return handleContentMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1420,7 +1429,7 @@ public class HttpParser
|
|||
{
|
||||
// Be forgiving of missing last CRLF
|
||||
setState(State.CLOSED);
|
||||
return _handler.messageComplete();
|
||||
return handleContentMessage();
|
||||
}
|
||||
setState(State.CLOSED);
|
||||
_handler.earlyEOF();
|
||||
|
@ -1477,7 +1486,7 @@ public class HttpParser
|
|||
if (content == 0)
|
||||
{
|
||||
setState(State.END);
|
||||
return _handler.messageComplete();
|
||||
return handleContentMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1501,7 +1510,7 @@ public class HttpParser
|
|||
if (content == 0)
|
||||
{
|
||||
setState(State.END);
|
||||
return _handler.messageComplete();
|
||||
return handleContentMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1524,7 +1533,7 @@ public class HttpParser
|
|||
if(_contentPosition == _contentLength)
|
||||
{
|
||||
setState(State.END);
|
||||
return _handler.messageComplete();
|
||||
return handleContentMessage();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1551,7 +1560,11 @@ public class HttpParser
|
|||
if (ch == HttpTokens.LINE_FEED)
|
||||
{
|
||||
if (_chunkLength == 0)
|
||||
{
|
||||
setState(State.TRAILER);
|
||||
if (_handler.contentComplete())
|
||||
return true;
|
||||
}
|
||||
else
|
||||
setState(State.CHUNK);
|
||||
}
|
||||
|
@ -1568,7 +1581,11 @@ public class HttpParser
|
|||
if (ch == HttpTokens.LINE_FEED)
|
||||
{
|
||||
if (_chunkLength == 0)
|
||||
{
|
||||
setState(State.TRAILER);
|
||||
if (_handler.contentComplete())
|
||||
return true;
|
||||
}
|
||||
else
|
||||
setState(State.CHUNK);
|
||||
}
|
||||
|
@ -1729,6 +1746,8 @@ public class HttpParser
|
|||
|
||||
public boolean headerComplete();
|
||||
|
||||
public boolean contentComplete();
|
||||
|
||||
public boolean messageComplete();
|
||||
|
||||
/**
|
||||
|
|
|
@ -231,6 +231,12 @@ public class HttpGeneratorServerHTTPTest
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messageComplete()
|
||||
{
|
||||
|
|
|
@ -2044,6 +2044,12 @@ public class HttpParserTest
|
|||
_trailers.add(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messageComplete()
|
||||
{
|
||||
|
|
|
@ -329,6 +329,12 @@ public class HttpTester
|
|||
add(field.getName(),field.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messageComplete()
|
||||
{
|
||||
|
|
|
@ -114,7 +114,10 @@ public class HttpChannelOverHTTP2 extends HttpChannel
|
|||
|
||||
boolean endStream = frame.isEndStream();
|
||||
if (endStream)
|
||||
{
|
||||
onContentComplete();
|
||||
onRequestComplete();
|
||||
}
|
||||
|
||||
_delayedUntilContent = getHttpConfiguration().isDelayDispatchUntilContent() &&
|
||||
!endStream && !_expect100Continue;
|
||||
|
@ -150,6 +153,7 @@ public class HttpChannelOverHTTP2 extends HttpChannel
|
|||
{
|
||||
onRequest(request);
|
||||
getRequest().setAttribute("org.eclipse.jetty.pushed", Boolean.TRUE);
|
||||
onContentComplete();
|
||||
onRequestComplete();
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
|
@ -255,7 +259,11 @@ public class HttpChannelOverHTTP2 extends HttpChannel
|
|||
|
||||
boolean endStream = frame.isEndStream();
|
||||
if (endStream)
|
||||
handle |= onRequestComplete();
|
||||
{
|
||||
boolean handle_content = onContentComplete();
|
||||
boolean handle_request = onRequestComplete();
|
||||
handle |= handle_content | handle_request;
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
|
|
|
@ -581,13 +581,22 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
|||
public boolean onContent(HttpInput.Content content)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} content {}", this, content);
|
||||
LOG.debug("{} onContent {}", this, content);
|
||||
|
||||
return _request.getHttpInput().addContent(content);
|
||||
}
|
||||
|
||||
public boolean onContentComplete()
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} onContentComplete", this);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onTrailers(HttpFields trailers)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} onTrailers {}", this, trailers);
|
||||
_request.setTrailers(trailers);
|
||||
}
|
||||
|
||||
|
|
|
@ -467,14 +467,20 @@ public class HttpChannelOverHttp extends HttpChannel implements HttpParser.Reque
|
|||
_httpConnection.getGenerator().setPersistent(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentComplete()
|
||||
{
|
||||
boolean handle = onContentComplete() || _delayedForContent;
|
||||
_delayedForContent = false;
|
||||
return handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messageComplete()
|
||||
{
|
||||
if (_trailers != null)
|
||||
onTrailers(_trailers);
|
||||
boolean handle = onRequestComplete() || _delayedForContent;
|
||||
_delayedForContent = false;
|
||||
return handle;
|
||||
return onRequestComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -421,6 +421,12 @@ public class LocalConnector extends AbstractConnector
|
|||
public void parsedHeader(HttpField field)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messageComplete()
|
||||
|
|
|
@ -328,6 +328,66 @@ public class HttpConnectionTest
|
|||
checkContains(response,offset,"/R1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChunk() throws Exception
|
||||
{
|
||||
String response=connector.getResponse("GET /R1 HTTP/1.1\r\n"+
|
||||
"Host: localhost\r\n"+
|
||||
"Transfer-Encoding: chunked\r\n"+
|
||||
"Content-Type: text/plain\r\n"+
|
||||
"Connection: close\r\n"+
|
||||
"\r\n"+
|
||||
"A\r\n" +
|
||||
"0123456789\r\n"+
|
||||
"0\r\n" +
|
||||
"\r\n");
|
||||
|
||||
int offset=0;
|
||||
offset = checkContains(response,offset,"HTTP/1.1 200");
|
||||
offset = checkContains(response,offset,"/R1");
|
||||
checkContains(response,offset,"0123456789");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChunkTrailer() throws Exception
|
||||
{
|
||||
String response=connector.getResponse("GET /R1 HTTP/1.1\r\n"+
|
||||
"Host: localhost\r\n"+
|
||||
"Transfer-Encoding: chunked\r\n"+
|
||||
"Content-Type: text/plain\r\n"+
|
||||
"Connection: close\r\n"+
|
||||
"\r\n"+
|
||||
"A\r\n" +
|
||||
"0123456789\r\n"+
|
||||
"0\r\n" +
|
||||
"Trailer: ignored\r\n" +
|
||||
"\r\n");
|
||||
|
||||
int offset=0;
|
||||
offset = checkContains(response,offset,"HTTP/1.1 200");
|
||||
offset = checkContains(response,offset,"/R1");
|
||||
checkContains(response,offset,"0123456789");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChunkNoTrailer() throws Exception
|
||||
{
|
||||
String response=connector.getResponse("GET /R1 HTTP/1.1\r\n"+
|
||||
"Host: localhost\r\n"+
|
||||
"Transfer-Encoding: chunked\r\n"+
|
||||
"Content-Type: text/plain\r\n"+
|
||||
"Connection: close\r\n"+
|
||||
"\r\n"+
|
||||
"A\r\n" +
|
||||
"0123456789\r\n"+
|
||||
"0\r\n");
|
||||
|
||||
int offset=0;
|
||||
offset = checkContains(response,offset,"HTTP/1.1 200");
|
||||
offset = checkContains(response,offset,"/R1");
|
||||
checkContains(response,offset,"0123456789");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHead() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue