我正在与 IIS Web 服务器建立 HTTP 连接,并发送一个 POST 请求,其中包含使用 Transfer-Encoding: chunked 编码的数据。当我这样做时,IIS 只是关闭连接,没有错误消息或状态代码。根据HTTP 1.1 spec ,
All HTTP/1.1 applications MUST be able to receive and decode the "chunked" transfer-coding
所以我不明白为什么它 (a) 不处理该编码以及 (b) 它不发回状态代码。如果我将请求更改为发送 Content-Length 而不是 Transfer-Encoding,查询就会成功,但这并不总是可能的。
当我对 Apache 尝试同样的操作时,我得到了“411 Length required”状态和一条消息“chunked Transfer-Encoding forbidden”。
为什么这些服务器不支持这种编码?
最佳答案
看看你的客户。
IIS 和 Apache 都支持使用分块传输编码的 POST 请求。您可以使用 curl utility 来验证这一点:
curl <upload-url> --form "upfile=@<local_file>" --header "Transfer-Encoding: chunked"
使用 Wireshark 验证传输是否分块
关于apache - 为什么 IIS 不支持分块传输编码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/338624/