Merge branch 'jetty-9.3.x' of github.com:eclipse/jetty.project into jetty-9.3.x

This commit is contained in:
Joakim Erdfelt 2017-02-02 15:54:27 -07:00
commit 0254854299
12 changed files with 161 additions and 23 deletions

View File

@ -260,6 +260,13 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
return !proceed || async;
}
@Override
public boolean contentComplete()
{
return false;
}
@Override
public boolean messageComplete()
{

View File

@ -284,6 +284,12 @@ public class ResponseContentParser extends StreamContentParser
}
}
@Override
public boolean contentComplete()
{
return false;
}
@Override
public boolean messageComplete()
{

View File

@ -175,6 +175,7 @@ public class ServerFCGIConnection extends AbstractConnection
LOG.debug("Request {} end on {}", request, channel);
if (channel != null)
{
channel.onContentComplete();
channel.onRequestComplete();
}
}

View File

@ -583,6 +583,24 @@ public class HttpParser
return s;
}
/* ------------------------------------------------------------------------------- */
private boolean handleHeaderContentMessage()
{
boolean handle_header = _handler.headerComplete();
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
*/
@ -730,10 +748,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
{
@ -801,10 +816,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)
@ -1071,10 +1083,7 @@ public class HttpParser
case NO_CONTENT:
setState(State.END);
handle=_handler.headerComplete()||handle;
_headerComplete=true;
handle=_handler.messageComplete()||handle;
return handle;
return handleHeaderContentMessage();
default:
setState(State.CONTENT);
@ -1334,7 +1343,7 @@ public class HttpParser
if (_responseStatus>0 && _headResponse)
{
setState(State.END);
return _handler.messageComplete();
return handleContentMessage();
}
else
{
@ -1391,7 +1400,7 @@ public class HttpParser
case EOF_CONTENT:
case CHUNK_END:
setState(State.CLOSED);
return _handler.messageComplete();
return handleContentMessage();
case CONTENT:
case CHUNKED_CONTENT:
@ -1467,7 +1476,7 @@ public class HttpParser
if (content == 0)
{
setState(State.END);
return _handler.messageComplete();
return handleContentMessage();
}
}
@ -1491,7 +1500,7 @@ public class HttpParser
if (content == 0)
{
setState(State.END);
return _handler.messageComplete();
return handleContentMessage();
}
else
{
@ -1514,7 +1523,7 @@ public class HttpParser
if(_contentPosition == _contentLength)
{
setState(State.END);
return _handler.messageComplete();
return handleContentMessage();
}
}
break;
@ -1541,7 +1550,11 @@ public class HttpParser
if (ch == HttpTokens.LINE_FEED)
{
if (_chunkLength == 0)
{
setState(State.CHUNK_END);
if (_handler.contentComplete())
return true;
}
else
setState(State.CHUNK);
}
@ -1558,7 +1571,11 @@ public class HttpParser
if (ch == HttpTokens.LINE_FEED)
{
if (_chunkLength == 0)
{
setState(State.CHUNK_END);
if (_handler.contentComplete())
return true;
}
else
setState(State.CHUNK);
}
@ -1736,6 +1753,8 @@ public class HttpParser
public boolean headerComplete();
public boolean contentComplete();
public boolean messageComplete();
/**

View File

@ -231,6 +231,12 @@ public class HttpGeneratorServerHTTPTest
return false;
}
@Override
public boolean contentComplete()
{
return true;
}
@Override
public boolean messageComplete()
{

View File

@ -1986,6 +1986,12 @@ public class HttpParserTest
return false;
}
@Override
public boolean contentComplete()
{
return false;
}
@Override
public boolean messageComplete()
{

View File

@ -310,6 +310,12 @@ public class HttpTester
add(field.getName(),field.getValue());
}
@Override
public boolean contentComplete()
{
return false;
}
@Override
public boolean messageComplete()
{

View File

@ -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())
{

View File

@ -624,6 +624,13 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
return _request.getHttpInput().addContent(content);
}
public boolean onContentComplete()
{
if (LOG.isDebugEnabled())
LOG.debug("{} onContentComplete", this);
return false;
}
public boolean onRequestComplete()
{
if (LOG.isDebugEnabled())

View File

@ -458,13 +458,19 @@ public class HttpChannelOverHttp extends HttpChannel implements HttpParser.Reque
}
@Override
public boolean messageComplete()
public boolean contentComplete()
{
boolean handle = onRequestComplete() || _delayedForContent;
boolean handle = onContentComplete() || _delayedForContent;
_delayedForContent = false;
return handle;
}
@Override
public boolean messageComplete()
{
return onRequestComplete();
}
@Override
public int getHeaderCacheSize()
{

View File

@ -425,6 +425,12 @@ public class LocalConnector extends AbstractConnector
{
}
@Override
public boolean contentComplete()
{
return false;
}
@Override
public boolean messageComplete()
{

View File

@ -152,7 +152,7 @@ public class HttpConnectionTest
@Test
public void testDate() throws Exception
{
String response=connector.getResponses("GET / HTTP/1.1\r\n"+
String response=connector.getResponse("GET / HTTP/1.1\r\n"+
"Host: localhost:80\r\n"+
"Connection: close\r\n"+
"\r\n");
@ -265,7 +265,7 @@ public class HttpConnectionTest
@Test
public void testEmptyChunk() throws Exception
{
String response=connector.getResponses("GET /R1 HTTP/1.1\r\n"+
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"+
@ -279,6 +279,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
{
@ -723,7 +783,7 @@ public class HttpConnectionTest
try
{
int offset=0;
response=connector.getResponses("GET /R1 HTTP/1.1\r\n"+
response=connector.getResponse("GET /R1 HTTP/1.1\r\n"+
"Host: localhost\r\n"+
"Connection: TE, close\r\n"+
"Transfer-Encoding: chunked\r\n"+