vert-x3 / vertx-web

HTTP web applications for Vert.x
Apache License 2.0
1.11k stars 535 forks source link

HTTP/1.0 requests without a host header must be handled by the router #2638

Closed tsegismont closed 2 months ago

tsegismont commented 3 months ago

This is a regression introduced in https://github.com/vert-x3/vertx-web/pull/2612

Can be reproduced with:

package io.vertx.ext.web;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;

public class TestVerticle extends AbstractVerticle {

  public static void main(String[] args) {
    Vertx vertx = Vertx.vertx();
    vertx.deployVerticle(new TestVerticle())
      .onSuccess(id -> System.out.println("Deployed verticle " + id))
      .onFailure(Throwable::printStackTrace);
  }

  @Override
  public void start(Promise<Void> startPromise) throws Exception {
    Router router = Router.router(vertx);

    router.get().handler(rc -> {
      System.out.println("rc.request().authority() = " + rc.request().authority());
      rc.response().end("Hello World");
    });

    vertx.createHttpServer()
      .requestHandler(router)
      .listen(8080)
      .<Void>mapEmpty()
      .onComplete(startPromise);
  }
}

And then:

curl -v --http1.0  -H 'Host:'  localhost:8080

You will see something like this:

* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> GET / HTTP/1.0
> User-Agent: curl/8.6.0
> Accept: */*
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 400 Bad Request
< content-length: 11
< 
* Closing connection
Bad Request

And the application logs to the console:

Unhandled exception in router

Without further details.

Original problem reported by a Quarkus user in: https://github.com/quarkusio/quarkus/discussions/42636

Note that it is common for network proxies (nginx, haproxy) to use HTTP/1.0 for health check requests.

Expectations:

pendula95 commented 3 months ago

I think this was already reported and waiting merge with https://github.com/vert-x3/vertx-web/issues/2629 and https://github.com/vert-x3/vertx-web/pull/2630

cescoffier commented 2 months ago

Any ETA - we need this fix in Quarkus (with a backport in the LTS version)

vietj commented 2 months ago

we will give an ETA this week @cescoffier