Description
Jetty version(s)
12.0.19
Jetty Environment
All
Description
When an error occurs on HTTP/1.1 during the parsing of a request, the error will be processed through the server/core level ErrorHandler
Example request:
GET /dump/%7= HTTP/1.1
Host: localhost
Connection: close
This will fail in the HTTP/1.1 parser (in the HttpURI
parsing)
Caused by: java.lang.NumberFormatException: !hex =
at org.eclipse.jetty.util.TypeUtil.convertHexDigit(TypeUtil.java:452)
at org.eclipse.jetty.http.HttpURI$Mutable.parse(HttpURI.java:1455)
at org.eclipse.jetty.http.HttpURI$Mutable.path(HttpURI.java:1005)
The error handling for this will reach the server / core-level ErrorHandler
to produce a response from.
But if the same request is sent via HTTP/2, then the connection is closed without producing a response, and without calling the server / core level ErrorHandler
.
at org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory$HTTPServerSessionListener.onClose(HTTP2ServerConnectionFactory.java:123)
at org.eclipse.jetty.http2.HTTP2Session.notifyClose(HTTP2Session.java:1218)
at org.eclipse.jetty.http2.HTTP2Session$StreamsState.terminate(HTTP2Session.java:2145)
at org.eclipse.jetty.http2.HTTP2Session$StreamsState.onSessionFailure(HTTP2Session.java:2027)
at org.eclipse.jetty.http2.HTTP2Session.onSessionFailure(HTTP2Session.java:601)
at org.eclipse.jetty.http2.HTTP2Session.onConnectionFailure(HTTP2Session.java:596)
at org.eclipse.jetty.http2.HTTP2Connection.onConnectionFailure(HTTP2Connection.java:300)
at org.eclipse.jetty.http2.parser.BodyParser.notifyConnectionFailure(BodyParser.java:218)
at org.eclipse.jetty.http2.parser.BodyParser.connectionFailure(BodyParser.java:210)
at org.eclipse.jetty.http2.parser.Parser.connectionFailure(Parser.java:241)
Is it possible to send an error response in these kinds of HTTP2 errors cases? or is a harsh close the only option?
If you manage to send the path /dump/%7=
in an HTTP/2 client, the fundamental Parser.parse error is due to a NumberFormatException
.
java.lang.NumberFormatException: !hex =
at org.eclipse.jetty.util.TypeUtil.convertHexDigit(TypeUtil.java:452)
at org.eclipse.jetty.http.HttpURI$Mutable.parse(HttpURI.java:1455)
at org.eclipse.jetty.http.HttpURI$Mutable.pathQuery(HttpURI.java:1031)
at org.eclipse.jetty.http.MetaData$Request.(MetaData.java:158)
at org.eclipse.jetty.http2.hpack.internal.MetaDataBuilder.build(MetaDataBuilder.java:269)
at org.eclipse.jetty.http2.hpack.HpackDecoder.decode(HpackDecoder.java:305)
at org.eclipse.jetty.http2.parser.HeaderBlockParser.parse(HeaderBlockParser.java:103)
at org.eclipse.jetty.http2.parser.HeadersBodyParser.parse(HeadersBodyParser.java:197)
at org.eclipse.jetty.http2.parser.Parser.parseBody(Parser.java:230)
at org.eclipse.jetty.http2.parser.Parser.parse(Parser.java:157)
at org.eclipse.jetty.http2.parser.ServerParser.parse(ServerParser.java:121)