Search code examples
phpdownloadheaderhtml-head

download limit of getting headers in php


Does php native function get_headers() downloads all the content, or stops downloading after getting header?


Solution

  • get_headers only graps header part of the response, and drops the connection.

    I enter interactive mode using php -a issued the command :

    php > print_r( get_headers('http://ftp.linux.org.tr/ubuntu-releases//maverick/ubuntu-10.10-desktop-i386.iso'));
    Array
    (
    [0] => HTTP/1.1 200 OK
    [1] => Date: Sat, 30 Oct 2010 23:33:12 GMT
    [2] => Server: Apache/2.2.13 (FreeBSD)
    [3] => Last-Modified: Thu, 07 Oct 2010 16:25:11 GMT
    [4] => ETag: "c7e78fe-2b528000-492095688a7c0"
    [5] => Accept-Ranges: bytes
    [6] => Content-Length: 726827008
    [7] => Connection: close
    [8] => Content-Type: application/octet-stream
    )
    

    This took less than 1 sec. Since chrome says It took 1 day to download ubuntu, compared to 1sec response of get_headers, it should be gather only headers.