curl 错误 18 - 传输关闭,剩余读取数据未完成 [英] curl error 18 - transfer closed with outstanding read data remaining
问题描述
当使用 curl 从 URL 检索数据时,我有时(在 80% 的情况下)得到
when retrieving data from a URL using curl, I sometimes (in 80% of the cases) get
错误 18:传输关闭,剩余未读数据
然后丢失了部分返回的数据.奇怪的是,当 CURLOPT_RETURNTRANSFER 设置为 false 时,这永远不会发生,即 curl_exec 函数不返回数据而是直接显示内容.
Part of the returned data is then missing. The weird thing is that this does never occur when the CURLOPT_RETURNTRANSFER is set to false, that is the curl_exec function doesn't return the data but displays the content directly.
可能是什么问题?我可以设置一些选项来避免这种行为吗?
What could be the problem? Can I set some of the options to avoid such behaviour?
推荐答案
我敢打赌这与对等方发送的错误 Content-Length
标头有关.我的建议是让 curl 自己设置长度.
I bet this is related to a wrong Content-Length
header sent by the peer.
My advice is to let curl set the length by itself.
这篇关于curl 错误 18 - 传输关闭,剩余读取数据未完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!