PHP curl_multi_getcontent接收到部分正文 [英] PHP curl_multi_getcontent partial body received

查看:170
本文介绍了PHP curl_multi_getcontent接收到部分正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力解决这个问题.

I'm struggling on this problem.

我要拿的尸体不是一个大的3100个字符. Apache在服务器上登录时说内容长度为3100.但是,curl_multi_getcontent返回的字符串被削减为1290个字符.

The body I am fetching is not a big one, 3100 chars. Apache logs on the server says the content length was 3100. However, the string returned by curl_multi_getcontent was cut to 1290 characters.

通常curl_multi_getcontent()可以正常工作,但有时我们会得到这种奇怪的行为.

Usually curl_multi_getcontent() works fine, but sometimes we get this weird behaviour.

有什么想法吗?

推荐答案

我的代码缺少正在进行的传输检查.

My code was missing the check for transfers in progress.

正在进行转移:

http_code = 200
errno = 0
download_content_length = total length, e.g. 1M
size_download = current position, <= download_content_length

似乎while(curlm_multi_exec == CURLM_CALL_MULTI_PERFORM)有点不足. 我们必须循环访问usleep,直到该URL的大小匹配或第二个参数multi_exec宣布所有URL完成为止.

Seems the while( curlm_multi_exec == CURLM_CALL_MULTI_PERFORM ) is somewhat insufficient. We have to loop with usleep until sizes match for this url or multi_exec second argument announces all urls finished.

复制步骤:

  • PHP< 5.2,一个网址,传输时间为几秒钟.

这篇关于PHP curl_multi_getcontent接收到部分正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆