Closed danielrichman closed 9 years ago
Another thing replace:
xhr.getResponseHeader("Content-Length");
with
parseInt(xhr.getResponseHeader("Content-Length"));
If we get Content-Length
header more than once, getReponseHeader
will return "100, 100"
and when we do (log_file_size - 1)
we get NaN
and everything is sad.
I think this is correct "behaviour" in the sense that I'm pretty sure (?) a Content-Length of "100, 100" / several content length headers is invalid and should be rejected.
Note that if we get "100, 100"
it will fail the isNaN
check immediately below.
However, I do agree that we should explicitly convert to integers. I intend to use this idiom:
var x = +y;
instead of parseInt
, because parseInt
will parse "15asdfasdf"
as 15
.
Oh, but +s
will convert floats; "123456.123". :-( MDN suggests REGEXing the string before using parseInt
Varnish does that. We get 100, 100
and we only need the first one, so parseInt()
is fine. It will stop at the ,
.
I disagree. This is a problem I think we should first look at fixing in Varnish, rather than hacking around it in JS: it is not legal to send Content-Length twice. Is this caused by the do_stream
thing? Perhaps it is not meant to be used in that way? (Though even if it is not this is pretty dumb/weird on Varnish's part)
Oh I agree. Varnish is broken and needs to be updated. Using do_stream
is a hack to avoid the negative low end on content-range.
https://www.varnish-cache.org/trac/ticket/1323
Should be fixed in v4
OK to merge this then?
Includes and subsumes #8