]> Cypherpunks repositories - gostls13.git/commit
net/http: Fix Range off-by-one error
authorJed Denlea <jed@fastly.com>
Tue, 16 Dec 2014 08:24:19 +0000 (00:24 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 20 Dec 2014 23:42:44 +0000 (23:42 +0000)
commit474ce6903b0646101769b03e976f7f70527bab54
treed67a4b1bee716f5edc443d336758612542e68821
parent640c0f3849ca041b047fd02defea78aa29092812
net/http: Fix Range off-by-one error

Given a file of size N, a request for "Range: bytes=N-*" should
return a 416 [1].  Currently, it returns a 206 and a body of 0
bytes, with the illegal Content-Range of "bytes N-(N-1)/N" [2].

[1]: RFC 7233, sec 2.1: "If a valid byte-range-set includes at least one
byte-range-spec with a first-byte-pos that is less than the current
length of the representation, [...]".  sec 3.1: "If all of the
preconditions are true, the server supports the Range header field for
the target resource, and the specified range(s) are invalid or
unsatisfiable, the server SHOULD send a 416 (Range Not Satisfiable)
response."

[2]: RFC 7233, sec 4.2: "A Content-Range field value is invalid if it
contains a byte-range-resp that has a last-byte-pos value less than its
first-byte-pos value, [...]"

Fixes #8988

Change-Id: If3e1134e7815f5d361efea01873b29aafe3de817
Reviewed-on: https://go-review.googlesource.com/1862
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/fs.go
src/net/http/fs_test.go