diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 4f34c27075b4..e6da0a2d7364 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -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; @@ -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() diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java index 322823388d17..bf4dbe48da9d 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java @@ -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")); } /** diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java index b8fb6a799a31..4bd0699e4100 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java @@ -303,7 +303,7 @@ public void testBadVersion(String logType) throws Exception _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()