I have a PHP script that serves portions of a PDF file by byte ranges.
If an HTTP HEAD request is received, it should send back headers (including the PDF file size) but not the actual file contents. I have tried this:
header('HTTP/1.1 200 OK');
header('Content-Type: application/pdf');
header('Accept-Ranges: bytes');
header('Content-Length: '.filesize($Pathname));
die;
The problem is that something (I assume the web server == LiteSpeed) replaces the Content-Length header with Content-Length: 0
- which defeats the whole purpose.
Can anyone suggest what I should be doing? Thanks
$Pathname
is correct? – LanniDummy-Length: 1545019
andDummy-Exists: 1
(but alsoContent-Length: 0
) – DescryContent-Length
tends to be mangled when you have some sort of transparent compression. You should also test a real HEAD request because otherwise you're trying to send incorrect data and the unexpected can happen. – Teacart