Using PHP i am attempting to send HTTP 206 content. But somehow right after receiving headers clients report closed connection, even though i have confirmed that the content is being sent on the server.
I think it has something to do with the setup of the headers or somesuch. The top-level code is:
$headers['content-length'] = $range['end']-$range['start']+1;
header('HTTP/1.1 206 Partial Content');
header("Pragma: {$headers['pragma']}");
header("Cache-Control: {$headers['cache-control']}");
header("Content-type: {$headers['content-type']}");
header("Content-Disposition: {$headers['content-disposition']}; filename=\"{$headers['filename']}\"");
header("Content-range: {$range['start']}-{$range['end']}/{$reqFile['size']}");
header("Content-length: {$headers['content-length']}");
outputFileRange($reqFile['handle'], $range['start'], $range['end']);
when i attempt to get via wget:
$ wget -t 1 -d -SO /dev/null --header="X-Backend-Port: 80" --header="Range: bytes=50-" http://1.2.3.4/download/123.ogv
i get the following:
Setting --server-response (serverresponse) to 1
Setting --output-document (outputdocument) to /dev/null
Setting --header (header) to X-Backend-Port: 80
Setting --header (header) to Range: bytes=50-
DEBUG output created by Wget 1.13.4 on linux-gnu.
URI encoding = `UTF-8'
--2013-10-18 11:05:36-- http://1.2.3.4/download/123.ogv
Connecting to 1.2.3.4:80... connected.
Created socket 4.
Releasing 0x0855da38 (new refcount 0).
Deleting unused 0x0855da38.
---request begin---
GET /download/123.ogv HTTP/1.1
User-Agent: Wget/1.13.4 (linux-gnu)
Accept: */*
Host: 1.2.3.4
Connection: Keep-Alive
X-Backend-Port: 80
Range: bytes=50-
---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 206 Partial Content
Server: nginx/0.7.67
Date: Fri, 18 Oct 2013 07:05:36 GMT
Content-Type: application/octet-stream
Connection: keep-alive
X-Powered-By: PHP/5.3.3-7+squeeze17
Pragma:
Cache-Control:
Content-Disposition: attachment; filename="123.ogv"
Content-range: 50-6642903/6642903
Content-length: 6642854
---response end---
HTTP/1.1 206 Partial Content
Server: nginx/0.7.67
Date: Fri, 18 Oct 2013 07:05:36 GMT
Content-Type: application/octet-stream
Connection: keep-alive
X-Powered-By: PHP/5.3.3-7+squeeze17
Pragma:
Cache-Control:
Content-Disposition: attachment; filename="123.ogv"
Content-range: 50-6642903/6642903
Content-length: 6642854
Registered socket 4 for persistent reuse.
Disabling further reuse of socket 4.
Closed fd 4
Giving up.
Try to set Content-range: 50-6642902/6642903 according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With