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,一个网址,传输时间为几秒钟.