【发布时间】:2015-07-01 13:07:36
【问题描述】:
我使用httpkit 作为http 客户端。我尝试了许多解决方案来使标题Content-Type 成为application/json,但都失败了。
这是我的代码:
(require '[org.httpkit.client :as http])
(http/post
url
{ :query-params {"q" "foo, bar"}
:form-params {"q" "foo, bar"}
:headers {"Content-Type" "application/json; charset=utf-8"}})
使用上面的代码发布会得到response status 200,但Content-Type 是application/x-www-form-urlencoded。
如果删除行application/x-www-form-urlencoded,将得到response status 400。
PS:我以flask 作为网络服务器。
【问题讨论】:
-
您是否期望您的 request
Content-Type修改 responseContent-Type标头?如果是这样,那么您应该研究端点在您的 Web 服务器中的实现,而不是客户端。
标签: json clojure http-headers content-type http-kit