softwaremill / sttp

The Scala HTTP client you always wanted!
https://sttp.softwaremill.com
Apache License 2.0
1.45k stars 309 forks source link

akka http prints warnings when content length is explicitly specified #459

Closed yurique closed 4 years ago

yurique commented 4 years ago

With akka-http backend and a request like this:

    basicRequest
      .post(uri"https://some-uri.nowhere")
      .body(Map("a" -> "A"))
      .send()

akka http spams the log with warnings like the following:

a.a.ActorSystemImpl        WARN     Explicitly set HTTP header 'Content-Length: 183' is ignored, explicit `Content-Length` header is not allowed. Use the appropriate HttpEntity subtype.

(akka http version 10.1.11, sttp version 2.0.1)

As a workaround I did this:

    val r = basicRequest
      .post(uri"https://some-uri.nowhere")
      .body(Map("a" -> "A"))
    r.copy(headers = r.headers.filterNot(_.name == HeaderNames.ContentLength))
      .send()

but it's not too pretty :)

adamw commented 4 years ago

I think this should be fixed by #452 in 2.0.2. Can you check?

yurique commented 4 years ago

@adamw yeah, I'm not getting those warnings anymore. Thanks!