FormData
应该Content-Type
自动设置标题,但它不起作用。所以我尝试手动设置它,但我收到警告。
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!
在任何一种情况下,我从服务器得到的响应都是我没有设置Content-Type
标头时得到的响应。
我HttpEntity
是否正确地构建了管道?我应该使用编组器FormData
吗?