[Varnish] #1643: corrupt range response
Varnish
varnish-bugs at varnish-cache.org
Fri Jan 30 16:52:42 CET 2015
#1643: corrupt range response
--------------------------------------+--------------------
Reporter: Jay | Owner: phk
Type: defect | Status: new
Priority: normal | Milestone: Later
Component: varnishd | Version: trunk
Severity: normal | Resolution:
Keywords: byte-range request range |
--------------------------------------+--------------------
Comment (by jstrom):
Hi,
fgs on IRC thought my issues was related to this bug, so I'll repeat my
findings here:
I'm running varnish 4.0.3 on Mac OS 10.9.5 (dev) with a very basic VCL.
I have a GET request which is pass'ed directly in vcl_recv.
This request comes from FFMPeg and has a "Range: bytes=0-" header.
The backend will reply with "Transfer-Encoding: chunked". One single chunk
with 8220 bytes is present in the response.
Every now and then (2 out of 5 requests maybe), varnish returns the full
response. But some times it returns 206 Partial Content and "Content-
Range: bytes 0-2667/2668".
tcpdump indicates that varnish starts to reply after 3 response TCP
packets has arrived, i..e before full response has been obtained. This
response includes the Content-Range header. then nothing happens until it
has received the rest of the backend packets, at which time the frontend
connection is closed.
My solution for now is just to remove the "Range: bytes=0-" header in the
request, as I don't use that anyway.
One guess from IRC:
{{{
16:22:53 < thierr1> jstrom: still guessing but what could lead to such
a situation may be : varnish receives the range request, makes a
background fetch and has received only 2668 bytes when it replies
to client (streaming mode), so issues a 206 with the current content
it has. From my point of view, this is RFC compliant, but not necessarily
what is expected. Maybe you can check this with tcpdump, you will see
if varnish has received full response when it starts stre
}}}
I agree, it *might* be compliant but definitely not what I expected. Also,
no streaming stuff is enabled in the VCL, so I'd expect full reply.
These are the Client -> Varnish headers:
{{{
GET /some/path/to/file HTTP/1.1
User-Agent: Lavf/56.15.100
Accept: */*
Range: bytes=0-
Connection: close
Host: localhost:8081
Icy-MetaData: 1
HTTP/1.1 206 Partial Content
Date: Fri, 30 Jan 2015 14:14:13 GMT
Server: Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.1j DAV/2 PHP/5.6.4
X-Powered-By: PHP/5.6.4
Content-Type: application/x-mpegURL
X-Varnish: 100148
Age: 0
Via: 1.1 varnish-v4
Transfer-Encoding: chunked
Connection: close
Accept-Ranges: bytes
Content-Range: bytes 0-2667/2668
}}}
These are the Varnish -> Backend headers:
{{{
GET /some/path/to/file HTTP/1.1
User-Agent: Lavf/56.15.100
Accept: */*
Range: bytes=0-
Icy-MetaData: 1
X-Forwarded-For: ::1
Host: example.com
X-Varnish: 100149
HTTP/1.1 200 OK
Date: Fri, 30 Jan 2015 14:14:13 GMT
Server: Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.1j DAV/2 PHP/5.6.4
X-Powered-By: PHP/5.6.4
Transfer-Encoding: chunked
Content-Type: application/x-mpegURL
}}}
Full VCL:
{{{
vcl 4.0;
import std;
backend stream {
.host = "example.com";
.port = "80";
}
sub vcl_recv {
# Pipe unknown requests
if (req.method != "GET" &&
req.method != "HEAD" &&
req.method != "PUT" &&
req.method != "POST" &&
req.method != "TRACE" &&
req.method != "OPTIONS" &&
req.method != "DELETE") {
/* Non-RFC2616 or CONNECT which is weird. */
return (pipe);
}
# Kill range header
#unset req.http.Range;
set req.http.Host = "example.com";
if(req.url ~ ".ts$") {
return(hash);
}
return(pass);
}
sub vcl_backend_response {
if (bereq.url ~ "\.ts$") {
set beresp.uncacheable = false;
set beresp.ttl = 86400s;
}
return (deliver);
}
}}}
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1643#comment:10>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list