大佬教程收集整理的这篇文章主要介绍了php – Curl:传输关闭,剩余未完成的读取数据,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我明白了
并且内容部分传递
GET /stats/?stats_breakdown=track__track&campaign=&search_criteria=2&period=0&date_month=11&date_day=03&date_year=2015&start_date_month=11&start_date_day=03&start_date_year=2015&END_DATE_month=12&END_DATE_day=31&END_DATE_year=2014 http/1.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13 Host: domain.com Accept: */* Cookie: sessionid=xxg4gglsm7o3b224wihqz8od19wl31h1; csrftoken=JBpLxNtgAVvDEw2wNqvBnRmzDJIjxL6C Cache-Control: no-cache Connection: Keep-Alive Keep-Alive: 600 Accept-Language: en-us X-CSRFToken: SeN9bHryRK8FWLTLJIs5c6u9AZ47a8pR Content-Type: application/x-www-form-urlencoded Origin: https://domain.com Referer: https://domain.com * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * additional stuff not fine transfer.c:1037: 0 0 * http 1.1 or later with persistent connection,pipelining supported < http/1.1 200 OK < Server: Nginx/1.8.0 < Date: Wed,04 Nov 2015 12:54:05 GMT < Content-Type: text/html; charset=utf-8 < transfer-encoding: chunked < Connection: keep-alive < Vary: Accept-Encoding < Vary: Cookie,Accept-Language < P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM int nAV ONL PHY PRE PUR UNI" < Content-Language: en * replaced cookie csrftoken="JBpLxNtgAVvDEw2wNqvBnRmzDJIjxL6C" for domain domain.com,path /,expire 1478091245 < Set-Cookie: csrftoken=JBpLxNtgAVvDEw2wNqvBnRmzDJIjxL6c; expires=Wed,02-Nov-2016 12:54:05 GMT; Max-Age=31449600; Path=/; secure < * nread <= 0,bailing * transfer closed with outstanding read data remaining * Closing connection #0
这是我使用的PHP配置
function getHeaders() { $headers = array(); $headers[] = 'Cache-Control: no-cache'; $headers[] = 'Connection: Keep-Alive'; $headers[] = 'Keep-Alive: 600'; $headers[] = 'Accept-Language: en-us'; $headers[] = 'X-CSRFToken: SeN9bHryRK8FWLTLJIs5c6u9AZ47a8pR'; $headers[] = 'Content-Type: application/x-www-form-urlencoded'; $headers[] = 'Origin: https://domain.com'; $headers[] = 'Referer: https://domain.com'; return $headers; } curl_setopt($connection,CURLOPT_URL,$url); curl_setopt($connection,CURLOPT_RETURNTRANSFER,1); curl_setopt($connection,CURLOPT_FOLLOWLOCATION,truE); curl_setopt($connection,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($connection,CURLOPT_SSL_VERIFYPEER,falsE); curl_setopt($connection,CURLOPT_SSL_VERIFYHOST,CURLOPT_COOKIEFILE,'cookie.txt'); curl_setopt($connection,CURLOPT_COOKIEJAR,CURLOPT_CONNECTTIMEOUT,550000000); curl_setopt($connection,CURLOPT_TIMEOUT,5500000000); //timeout in seconds curl_setopt($connection,CURLOPT_httpHEADER,getHeaders()); curl_setopt($connection,CURLOPT_VERBOSE,1);
对我有帮助的是补充
--keepalive-time 2
卷曲选项的解释
--keepalive-time <seconds>
看起来默认值太高,无法保持连接打开.
这是我用来打电话的完整命令
curl URL -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: en-US,en;q=0.8,et;q=0.6,nl;q=0.4' -H 'Upgrade-Insecure-requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/45.0.2454.101 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Connection: keep-alive' --compressed -v --keepalive-time 2
而且我在osx上运行这个版本的curl
curl 7.43.0 (x86_64-apple-darwin15.0) libcurl/7.43.0 SecureTransport zlib/1.2.5 Protocols: Dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets
如果有人想在PHP curl中使用此选项,则自PHP 5.5起可以使用–keepalive-time选项.您可以按如下方式使用它:
curl_setopt($connection,CURLOPT_TCP_KEEPALIVE,1); curl_setopt($connection,CURLOPT_TCP_KEEPIDLE,2);
希望这可以帮助有人在同样的问题上挣扎!
以上是大佬教程为你收集整理的php – Curl:传输关闭,剩余未完成的读取数据全部内容,希望文章能够帮你解决php – Curl:传输关闭,剩余未完成的读取数据所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。