php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32906 Content length bug
Submitted: 2005-05-01 18:23 UTC Modified: 2005-05-01 18:58 UTC
From: papasha_papovich at mail dot ru Assigned:
Status: Not a bug Package: cURL related
PHP Version: 4.3.10 OS: Windows XP SP1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: papasha_papovich at mail dot ru
New email:
PHP Version: OS:

 

 [2005-05-01 18:23 UTC] papasha_papovich at mail dot ru
Description:
------------
I use CURL to get only the length of the document, I use CURLOPT_NOBODY option, it returns the response header ok, but with content-length field set to zero.

Reproduce code:
---------------
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.softmath.com");
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_exec($ch);
print_r(curl_getinfo($ch));
curl_close($ch);

Expected result:
----------------
Array
(
    [url] => http://www.softmath.com
    [content_type] => text/html
    [http_code] => 200
    [header_size] => 162
    [request_size] => 74
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.297
    [namelookup_time] => 0
    [connect_time] => 0.14
    [pretransfer_time] => 0.14
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => [the size of index page]
    [upload_content_length] => 0
    [starttransfer_time] => 0.297
    [redirect_time] => 0
)

Actual result:
--------------
Array
(
    [url] => http://www.softmath.com
    [content_type] => text/html
    [http_code] => 200
    [header_size] => 162
    [request_size] => 74
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.297
    [namelookup_time] => 0
    [connect_time] => 0.14
    [pretransfer_time] => 0.14
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => 0
    [upload_content_length] => 0
    [starttransfer_time] => 0.297
    [redirect_time] => 0
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-01 18:58 UTC] rasmus@php.net
That's not curl's fault.  If the server you are connecting to doesn't send a content-length response header, there is no way for curl to know the content-length.  The headers from http://www.softmath.com are:

HTTP/1.1 200 OK
Date: Sun, 01 May 2005 16:55:48 GMT
Server: Apache/1.3.33 (Unix) FrontPage/5.0.2.2635 mod_ssl/2.8.22 OpenSSL/0.9.7d
Connection: close
Content-Type: text/html

You will find that many servers won't send a content-length for dynamically generated content.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 06 08:01:26 2024 UTC