Closed b8b closed 2 months ago
All requests without host header are rejected with code 400. Technically, for HTTP/1.0 this might not be completely correct.
It is possible to handle such a request with a low level Handler
This is actually not h2 related. It happens when trying to access RoutingContext#request().authority() from within a failure handler (regardless of allowForward settings).
java.lang.NullPointerException: Cannot invoke "io.vertx.core.net.HostAndPort.host()" because "authority" is null
at io.vertx.ext.web.impl.ForwardedParser.setHostAndPort(ForwardedParser.java:195)
at io.vertx.ext.web.impl.ForwardedParser.calculate(ForwardedParser.java:114)
at io.vertx.ext.web.impl.ForwardedParser.authority(ForwardedParser.java:81)
at io.vertx.ext.web.impl.HttpServerRequestWrapper.authority(HttpServerRequestWrapper.java:188)
at TestVertx.testHttp10$lambda$0(TestVertx.kt:76)
at io.vertx.ext.web.impl.RoutingContextImplBase.unhandledFailure(RoutingContextImplBase.java:235)
The 2 issues are closely related. Documentation for HttpServerRequest#authority() informs explicitly about a nullable return value. HttpServerRequestWrapper#authority() should return null instead of throwing an NPE. Also, I see no strict reason to reject requests with null authority - it should always be handled by the user anyway.
Would you like to contribute a fix for this?
Would you like to contribute a fix for this?
Yes sure. I have created a commit in my fork: https://github.com/b8b/vertx-web/commit/a7edbe4531957a899c55703a3f586e25fa7c3497
Is it good to target the 4.x branch with a pull request or should it rather target the master branch?
Yes sure. I have created a commit in my fork: b8b@a7edbe4
Thank you !
Is it good to target the 4.x branch with a pull request or should it rather target the master branch?
We need to fix both the 4.x
and master
branches.
Fixed by #2640
Version
4.5.8
Context
When using a Router to handle http requests, sending an HTTP 1.0 request without host header triggers an exception.
Do you have a reproducer?
Additional observation
An h2 request with host header causes an NPE in the Router code.