Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x

This commit is contained in:
Joakim Erdfelt 2020-09-09 09:30:30 -05:00
commit 4215edd3b9
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
3 changed files with 21 additions and 13 deletions

View File

@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
import static org.eclipse.jetty.http.HttpCompliance.RFC7230;
import static org.eclipse.jetty.http.HttpCompliance.Violation;
import static org.eclipse.jetty.http.HttpCompliance.Violation.CASE_SENSITIVE_FIELD_NAME;
import static org.eclipse.jetty.http.HttpCompliance.Violation.HTTP_0_9;
import static org.eclipse.jetty.http.HttpCompliance.Violation.MULTIPLE_CONTENT_LENGTHS;
import static org.eclipse.jetty.http.HttpCompliance.Violation.NO_COLON_AFTER_FIELD_NAME;
import static org.eclipse.jetty.http.HttpCompliance.Violation.TRANSFER_ENCODING_WITH_CONTENT_LENGTH;
@ -750,12 +751,19 @@ public class HttpParser
case LF:
// HTTP/0.9
checkViolation(Violation.HTTP_0_9);
if (Violation.HTTP_0_9.isAllowedBy(_complianceMode))
{
reportComplianceViolation(HTTP_0_9, HTTP_0_9.getDescription());
_requestHandler.startRequest(_methodString, _uri.toString(), HttpVersion.HTTP_0_9);
setState(State.CONTENT);
_endOfContent = EndOfContent.NO_CONTENT;
BufferUtil.clear(buffer);
handle = handleHeaderContentMessage();
}
else
{
throw new BadMessageException(HttpStatus.HTTP_VERSION_NOT_SUPPORTED_505, "HTTP/0.9 not supported");
}
break;
case ALPHA:
@ -924,10 +932,10 @@ public class HttpParser
private void checkVersion()
{
if (_version == null)
throw new BadMessageException(HttpStatus.BAD_REQUEST_400, "Unknown Version");
throw new BadMessageException(HttpStatus.HTTP_VERSION_NOT_SUPPORTED_505, "Unknown Version");
if (_version.getVersion() < 10 || _version.getVersion() > 20)
throw new BadMessageException(HttpStatus.BAD_REQUEST_400, "Bad Version");
throw new BadMessageException(HttpStatus.HTTP_VERSION_NOT_SUPPORTED_505, "Unsupported Version");
}
private void parsedHeader()

View File

@ -158,14 +158,14 @@ public class HttpConnectionTest
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setHttpCompliance(HttpCompliance.RFC2616);
String request = "GET / HTTP/0.9\r\n\r\n";
String response = connector.getResponse(request);
assertThat(response, containsString("400 Bad Request"));
assertThat(response, containsString("reason: Bad Version"));
assertThat(response, containsString("505 HTTP Version Not Supported"));
assertThat(response, containsString("reason: Unsupported Version"));
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setHttpCompliance(HttpCompliance.RFC7230);
request = "GET / HTTP/0.9\r\n\r\n";
response = connector.getResponse(request);
assertThat(response, containsString("400 Bad Request"));
assertThat(response, containsString("reason: Bad Version"));
assertThat(response, containsString("505 HTTP Version Not Supported"));
assertThat(response, containsString("reason: Unsupported Version"));
}
/**

View File

@ -307,7 +307,7 @@ public class NcsaRequestLogTest
_connector.getResponse("METHOD /foo HTTP/9\n\n");
String log = _entries.poll(5, TimeUnit.SECONDS);
assertThat(log, containsString("\"- - -\""));
assertThat(log, containsString(" 400 "));
assertThat(log, containsString(" 505 "));
}
@ParameterizedTest()