FormData
is supposed to set the Content-Type
header automatically but it isn't working. So I tried to set it manually but I get a warning.
val gzipPipeline: HttpRequest => Future[HttpResponse] = encode(Gzip) ~> sendReceive ~> decode(Gzip)
val request =
(Post(uri,
FormData(Map(
"set_login" -> credentials.username,
"set_pass" -> credentials.password))
) ~> addHeader(`Content-Type`(`application/x-www-form-urlencoded`))
~> addHeader(`Accept-Encoding`(gzip)))
[WARN] [04/14/2016 02:09:50.803] [forPipeline-akka..default-dispatcher-8] [akka://forPipeline/user/IO-HTTP/group-0/0] Explicitly set request header 'Content-Type: application/x-www-form-urlencoded' is ignored, the request Content-Type is set via the request's HttpEntity!
In either case, the response I get from the server is the response that I get when I don't set the Content-Type
header.
Have I constructed the pipeline and HttpEntity
properly? Am I supposed to use a marshaller for FormData
?
I set the HttpRequest
properly but the server does not accept gzip-encoded requests. I just had to remove gzip encoding from the pipeline.