Skip to content

Instantly share code, notes, and snippets.

@t4kemyh4nd
Last active August 1, 2020 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t4kemyh4nd/e54d9382d4f2c1aaf5c018d72c73a2d5 to your computer and use it in GitHub Desktop.
Save t4kemyh4nd/e54d9382d4f2c1aaf5c018d72c73a2d5 to your computer and use it in GitHub Desktop.
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