Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #5233 - Bad/Unsupported HTTP version should return 505 not 400. #5234

Merged
merged 2 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ private boolean parseLine(ByteBuffer buffer)
case LF:
// HTTP/0.9
if (complianceViolation(HttpComplianceSection.NO_HTTP_0_9, "No request version"))
throw new BadMessageException("HTTP/0.9 not supported");
throw new BadMessageException(HttpStatus.HTTP_VERSION_NOT_SUPPORTED_505, "HTTP/0.9 not supported");
_requestHandler.startRequest(_methodString, _uri.toString(), HttpVersion.HTTP_0_9);
setState(State.CONTENT);
_endOfContent = EndOfContent.NO_CONTENT;
Expand Down Expand Up @@ -942,10 +942,10 @@ else if (n == HttpTokens.LINE_FEED)
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ public void testHttp09NoVersion() throws Exception
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
String request = "GET / HTTP/0.9\r\n\r\n";
String response = connector.getResponse(request);
assertThat(response, containsString("400 Bad Version"));
assertThat(response, containsString("505 Unsupported Version"));

connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC7230);
request = "GET / HTTP/0.9\r\n\r\n";
response = connector.getResponse(request);
assertThat(response, containsString("400 Bad Version"));
assertThat(response, containsString("505 Unsupported Version"));
}

/**
Expand Down