HTTP Bad chunk header 和 Illegal or missing hexadecimal sequence in chunked-encoding 解决方法

HTTP About 737 words

错误信息

错误一

org.apache.http.MalformedChunkCodingException: Bad chunk header: {"a":["b"],"c":["d"]}

错误二

curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding

原因

Connection: close必须放在Header中的最后一段。解析HTTP报文时,解析到Connection: close就不再继续解析之后的报文。

错误示例

< HTTP/1.1 400
< Connection: close
< Date: Thu, 13 Oct 2022 06:02:01 GMT
< Transfer-Encoding: chunked
< Content-Type: application/json
<
{ [21 bytes data]

正确示例

< HTTP/1.1 400
< Date: Thu, 13 Oct 2022 06:02:15 GMT
< Transfer-Encoding: chunked
< Content-Type: application/json
< Connection: close
<
{ [27 bytes data]

备注

400错误:默认Connectionclose

401错误:默认onnectionkeep-alive

参考

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection

Views: 2,080 · Posted: 2023-03-14

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh