• Jed Denlea's avatar
    net/http: Fix Range off-by-one error · 474ce690
    Jed Denlea authored
    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/1862Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    474ce690
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
include Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...