开发者

CURLOPT_NOBODY not working

I am using the following code

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $real_url);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, $fscookiefile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $fscookiefile);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13 GTB7.1');
$r = curl_exec($ch) or die('WHY DOES THIS DIE!!!');
curl_close($ch);

Which always results in WHY DOES THIS DIE!!! or the page keeps loading for sometime and then shows nothing if I don't use or die('WHY DOES THIS DIE!!!')

If I set CURLOPT_NOBODY to false

I get

HTTP/1.1 200 OK Date: Thu, 09 Jun 2011 01:35:07 GMT Pragma: public Expires: 0 Cache-Control: must-revalidate,开发者_开发百科 post-check=0, pre-check=0, private=false Content-Type: application/force-download Content-Transfer-Encoding: binary Keep-Alive: 1000 Content-Disposition: attachment; filename*= UTF-8''Ever17.part3.rar Accept-Ranges: bytes Content-Length: 520000000 Server: Jetty(6.1.16) Rar!zs sdt�NP�(�&R�%G��65,��Ever17\Ever_17_-_The_Out_of_Infinity_CD3.iso��"j����M�K�U:� >�b�2Q�sT?G��+iM���qN�'��&�-d�z�����} xi�<�3\�d��Z:|�/���@�gl��$��~@��u�וۊ \��jմg�)�L��#&��;��5M�s}���(�Đ$�yGwӏ$�E����$�Z���:�/�����r͐�8�&������#Q�00��>�)�n�̌}o�H����2Z���y�S㞝�H��=�9�[������E�nЭ��\�׊9Ǘ!{&y�j/���Ȇg������FW��~G�5������F-&����ƭ��9<���^7����(�HY(a����%�ɚQYL_���ܽ�X|��&

Why am I not getting any output with CURLOPT_NOBODY set to true ????

I am using PHP 5.1.6 on Apache/2.2.3 and have curl-7.15.5-9.el5_6.2.i386 installed


(That's a seriously outdated curl version)

Try using the command line version (preferably from the same host running that PHP script) like 'curl -I [URL]' and make sure the web site truly responds nice to a HEAD request.

Add -v or --trace-ascii for full debug/trace output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜