codecowboy
codecowboy

Reputation: 10104

Why is the Content-Length HTTP header from not the same as on disk file size?

If I use PHP's get_headers() to return the Content-Length of an image file, why does this not match the size of the file if I save it to disk (OSX)?

protected function checkRemoteFile($url)
{
    $headers = get_headers($url,1);
    $size = $headers['Content-Length'];
    return $size;

}

Upvotes: 1

Views: 438

Answers (1)

Julian Reschke
Julian Reschke

Reputation: 42065

Likely because the content was sent using Content-Encoding: gzip.

Upvotes: 4

Related Questions