http4s / http4s

A minimal, idiomatic Scala interface for HTTP

Home Page:https://http4s.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Query params are not sent with HTTP/2

ybasket opened this issue · comments

When sending request using an ember client with HTTP/2 enabled, query params are omitted, the server doesn't receive them. Without HTTP/2, query params are sent as expected. Same when using the JDK http client.

Reproducer (scala-cli friendly): https://gist.github.com/ybasket/ab3b4eff4fa6bd58209054a94ddb1772

  def run: IO[Unit] = EmberClientBuilder
    .default[IO]
    .withHttp2 // comment me to fix behaviour
    .build
    .use { client =>
      client.expect[String](Request(uri = uri"https://httpbin.org/anything?foo=bar")).flatMap(IO.println)
    }

Looks like that bit is just missing in the implementation since at least http4s 0.23.14:

val path = {
val s = req.uri.path.renderString
if (s.isEmpty) "/"
else s
}

According to https://httpwg.org/specs/rfc7540.html#rfc.section.8.1.2.3, the query should be included in the :path pseudo header. There's also a special handling of OPTIONS in the RFC that is not implemented.