燃料库-无法发送没有默认标头的请求。
我正在尝试发送不带Content-Type头的示范性请求:
Fuel.post("http://endpoint/...")
.also { it.headers.clear() }
.also { log.debug { "Headers: $it.headers" }}
.body("...body...".toByteArray(Charset.ISO_8859_1))
.response { request, response, result -> log.debug { "Response: $response" }}
但是在服务器端,它看起来(从服务器日志中读取)这个请求是通过
Content-type application/x-www-form-urlencoded
客户端的日志没有显示发送了这样的'content-type‘元素:
Headers: --> http://endpoint/...
"Body : (empty)"
"Headers : (0)"
我做错了什么吗?你注意到这样的行为了吗?
如何在使用燃料库时不发送Content-type头部?
发布于 2020-03-31 12:56:36
我不知道为什么Fuel要添加这个默认的头部,但是你有两个选择不发送这个头部:
.header(mapOf("Content-Type“to "application/json"))
request.headers.clear()
https://stackoverflow.com/questions/60467944
复制