Last active
August 1, 2020 03:33
-
-
Save t4kemyh4nd/e54d9382d4f2c1aaf5c018d72c73a2d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if size >= 0 { | |
ranges, err := parseRange(rangeReq, size) | |
if err != nil { | |
if err == errNoOverlap { | |
w.Header().Set("Content-Range", fmt.Sprintf("bytes */%d", size)) | |
} | |
Error(w, err.Error(), StatusRequestedRangeNotSatisfiable) | |
return | |
} | |
if sumRangesSize(ranges) > size { | |
// The total number of bytes in all the ranges | |
// is larger than the size of the file by | |
// itself, so this is probably an attack, or a | |
// dumb client. Ignore the range request. | |
ranges = nil | |
} | |
switch { | |
case len(ranges) == 1: | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment