|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-08-29 04:15 UTC] djimenez at conduit-it dot com
Description:
------------
Apache2 supports byte range response with an output filter. Static files
over 8000 bytes work fine, but mod_php5 served content only works
correctly if it is <= 8000 bytes
To test I used telnet to submit an HTTP Range request for the included
PHP file from an apache2 server configured with mod_php5. Example
requests are in the actual results.
Reproduce code:
---------------
<?php
// upto and including 8000 bytes will allow the byterange filter to work
//
// NOTE: 8000 byte limit was found by manual trial and error, may vary per system, but
// my guess would be it has to do with a byte buffer either in mod_php5 or apache2
echo str_repeat(".", 8000);
// anything over 8000 bytes will "fail" (full response)
//echo "\n...one toke over the line";
?>
Expected result:
----------------
Apache's byterange output filter should handle range requests for PHP
responses > 8000 bytes.
Actual result:
--------------
While the test scripts second echo is commented, I get the expected
results:
$ telnet dev.conduit-it.com 80
Trying 10.42.84.2...
Connected to dev.conduit-it.com.
Escape character is '^]'.
GET /test.php HTTP/1.1
Host:dev.conduit-it.com
Range:bytes=0-24
Connection:close
HTTP/1.1 206 Partial Content
Date: Fri, 29 Aug 2008 03:43:20 GMT
Content-Range: bytes 0-24/8000
Content-Length: 25
Connection: close
Content-Type: text/html
.........................Connection closed by foreign host.
We can also see it working for multiple ranges:
$ telnet dev.conduit-it.com 80
Trying 10.42.84.2...
Connected to dev.conduit-it.com.
Escape character is '^]'.
GET /test.php HTTP/1.1
Host:dev.conduit-it.com
Range:bytes=0-24,50-74
Connection:close
HTTP/1.1 206 Partial Content
Date: Fri, 29 Aug 2008 03:45:44 GMT
Content-Length: 240
Connection: close
Content-Type: multipart/byteranges; boundary=455911696d6f354a2
--455911696d6f354a2
Content-type: text/html
Content-range: bytes 0-24/8000
.........................
--455911696d6f354a2
Content-type: text/html
Content-range: bytes 50-74/8000
.........................
--455911696d6f354a2--
Connection closed by foreign host.
So apache is doing all the work for us, until we uncomment the second
echo statement in the repro. script. This puts us over the 8000 byte
limit. At that point, both example requests will return full 200 OK
responses (so content is 8000 periods + our message)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
I can confirm this problem. Exactly over 8000 Bytes it does not work anymore. Also using the Apache module x-sendfile does not solve this error in my case. The one and only work-around in my case is a header call with location of a static url. header('Location: http://any.url/toanyfile.html'); exit; After this just Apache controls the range operator and it works as expected.I hope someone will find this useful EXPLICITLY adding header("Transfer-Encoding: chunked"); solved the problem (not sure how reliably though). That Transfer-Encoding header was being added automatically even if i didn't set it - but the problem was there. Adding the header explicitly in PHP code solved it. Tested using websniffer.cc, PHP 7.4.9 CentOS 7.8