vertx-web icon indicating copy to clipboard operation
vertx-web copied to clipboard

HTTP 1.0 request causes "Unhandled exception in router"

Open b8b opened this issue 1 year ago • 3 comments

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?

    @Test
    fun testHttp10() {
        val vertx = Vertx.vertx()
        val router = Router.router(vertx)
        router.get("/").handler { ctx ->
            ctx.response().end("hello\n")
        }
        runBlocking(vertx.dispatcher()) {
            val server = vertx.createHttpServer()
                .requestHandler(router)
                .listen(0)
                .coAwait()
            val client = vertx.createNetClient()
                .connect(server.actualPort(), "localhost")
                .coAwait()
            val rx = client.toReceiveChannel(vertx)
            val tx = client.toSendChannel(vertx)
            tx.send(Buffer.buffer("GET / HTTP/1.0\r\n" +
                    "Connection: close\r\n" +
                    "\r\n"))
            val answer = rx.receive().toString(Charsets.UTF_8)
            client.close()
            server.close()
            println(answer)
            assertTrue(answer.startsWith("200"))
        }
    }

Additional observation

An h2 request with host header causes an NPE in the Router code.

b8b avatar Jun 28 '24 17:06 b8b