1
0
mirror of https://github.com/golang/go synced 2024-11-20 05:14:41 -07:00

http: avoid crash when asked for multiple file ranges

R=adg
CC=golang-dev
https://golang.org/cl/4289076
This commit is contained in:
Russ Cox 2011-03-27 23:35:31 -04:00
parent 59a8926829
commit 732f2fa2c1

View File

@ -154,7 +154,10 @@ func serveFile(w ResponseWriter, r *Request, name string, redirect bool) {
// handle Content-Range header. // handle Content-Range header.
// TODO(adg): handle multiple ranges // TODO(adg): handle multiple ranges
ranges, err := parseRange(r.Header.Get("Range"), size) ranges, err := parseRange(r.Header.Get("Range"), size)
if err != nil || len(ranges) > 1 { if err == nil && len(ranges) > 1 {
err = os.ErrorString("multiple ranges not supported")
}
if err != nil {
Error(w, err.String(), StatusRequestedRangeNotSatisfiable) Error(w, err.String(), StatusRequestedRangeNotSatisfiable)
return return
} }