You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is very weird behavior in HttpServerrequest between vert.x and vertx-web. In vert.x when the host header is missing it returns null for authority() but returns an URI in absoluteURI(). Project vert.x executes some code to return the absolute URI based on the server origin. Nevertheless vertx-web returns null in both methods. Reading the javadoc for HttpServerRequest I think that authority can be null but absoluteURI not. I'm not happy with this because I don't understand that absoluteURI has an authority filled but the specific authority method returns null, but OK, I accept it. But then can vertx-web do the same?
I added this little diff to do the same in vertx-web too. I'm assigning initially the aboluteURI to the one returned by vert.x and modifying the testMissingHostHeader to assert is not null.
diff --git a/vertx-web/src/main/java/io/vertx/ext/web/impl/ForwardedParser.java b/vertx-web/src/main/java/io/vertx/ext/web/impl/ForwardedParser.java
index 557d6225e..53007ef51 100644
--- a/vertx-web/src/main/java/io/vertx/ext/web/impl/ForwardedParser.java+++ b/vertx-web/src/main/java/io/vertx/ext/web/impl/ForwardedParser.java@@ -106,6 +106,7 @@ class ForwardedParser {
remoteAddress = delegate.remoteAddress();
scheme = delegate.scheme();
setHostAndPort(delegate.authority());
+ absoluteURI = delegate.absoluteURI();
switch (allowForward) {
case X_FORWARD:
diff --git a/vertx-web/src/test/java/io/vertx/ext/web/ForwardedTest.java b/vertx-web/src/test/java/io/vertx/ext/web/ForwardedTest.java
index 2ed5e479b..5bf378a4c 100644
--- a/vertx-web/src/test/java/io/vertx/ext/web/ForwardedTest.java+++ b/vertx-web/src/test/java/io/vertx/ext/web/ForwardedTest.java@@ -433,6 +433,7 @@ public class ForwardedTest extends WebTestBase {
route.handler(rc -> {
assertNull(rc.request().authority());
+ assertNotNull(rc.request().absoluteURI());
rc.end();
});
Do you have a reproducer?
You can execute your own test ForwardedTest#testMissingHostHeader you will see that authority() is null (as in vert.x) but absolutyURI() is also null (while in vert.x is http://localhost:8080/).
The text was updated successfully, but these errors were encountered:
Version
4.5.7 but it's in master too.
Context
There is very weird behavior in
HttpServerrequest
between vert.x and vertx-web. In vert.x when the host header is missing it returnsnull
forauthority()
but returns an URI inabsoluteURI()
. Project vert.x executes some code to return the absolute URI based on the server origin. Nevertheless vertx-web returnsnull
in both methods. Reading the javadoc for HttpServerRequest I think thatauthority
can be null butabsoluteURI
not. I'm not happy with this because I don't understand thatabsoluteURI
has an authority filled but the specificauthority
method returns null, but OK, I accept it. But then can vertx-web do the same?I added this little diff to do the same in vertx-web too. I'm assigning initially the aboluteURI to the one returned by vert.x and modifying the
testMissingHostHeader
to assert is not null.Do you have a reproducer?
You can execute your own test
ForwardedTest#testMissingHostHeader
you will see thatauthority()
is null (as in vert.x) butabsolutyURI()
is also null (while in vert.x ishttp://localhost:8080/
).The text was updated successfully, but these errors were encountered: