Content-length and other HTTP headers?

I think its only because of the HTTP Spec says to do this in every case possible.

Applications SHOULD use this field to indicate the transfer-length of the message-body, unless this is prohibited by the rules in section 4.4.

You can also look at Pauls Answer on the Question of Deaomon.

I think this will answer yours too.

Also you should use Content-Length if you want someone download a file with another header:
e.g.

<?php
$file = "original.pdf"
$size = filesize($file);
header('Content-type: application/pdf');
header("Content-length: $size");
header('Content-Disposition: attachment; filename="downloaded.pdf"');
readfile($file);
?>

Leave a Comment