, , ...
206 http, . .
html5 :
Range: bytes=0- or..
Range: bytes=0-12345
spec:
HTTP/1.1 206 PARTIAL CONTENT
Accept-Ranges: bytes
Content-Range: bytes 0-12345
206 , .
Perl, , $request , . , SERVER_PROTOCOL "HTTP/1.1"
my $crlf = "\012";
if ( $request->{RANGE} && $request->{RANGE} =~ /bytes=(\d*)-(.*)$/ ) {
$offset = $1;
$end = $2 || $size;
$header = $request->{SERVER_PROTOCOL} . ' 206 PARTIAL CONTENT' . $crlf .
'Content-Range: bytes ' . $offset . '-' . $end . '/' . $size . $crlf;
} else {
$header = $request->{SERVER_PROTOCOL} . ' 200 OK' . $crlf;
}
my $left = $end - $offset;
$header .= 'Server: ' . $SERVER_NAME . $crlf .
'Accept-Ranges: bytes' . $crlf .
'Date: ' . $http_date . $crlf .
'Content-Type: ' . ($self->simplemime($raw_path) || magic($fh)) . $crlf .
'Last-Modified: ' . $http_date . $crlf .
'Content-Length: ' . $size . $crlf .
'Connection: Keep-Alive' . $crlf .
'Cache-Control: max-age=' . $EXPIRE . $crlf . $crlf;
, , , .
"" , , , Mojolicious, AnyEvent Node.js , 1 , PHP, . (, , Ratchet Xsendfile)
, :
Range: bytes=0-
, , ( ). HTTP/1.1 200 HTTP/1.1 206, . , , , , . , , .
, ... .