Browse Source

Remove "Content-Length" header if http.Error is issued (#5981)

pull/6002/head
Eugeniy E. Mikhailov 4 months ago
committed by GitHub
parent
commit
d6b0e0ff1c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      weed/server/common.go

4
weed/server/common.go

@ -303,11 +303,13 @@ func ProcessRangeRequest(r *http.Request, w http.ResponseWriter, totalSize int64
writeFn, err := prepareWriteFn(0, totalSize) writeFn, err := prepareWriteFn(0, totalSize)
if err != nil { if err != nil {
glog.Errorf("ProcessRangeRequest: %v", err) glog.Errorf("ProcessRangeRequest: %v", err)
w.Header().Del("Content-Length")
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return fmt.Errorf("ProcessRangeRequest: %v", err) return fmt.Errorf("ProcessRangeRequest: %v", err)
} }
if err = writeFn(bufferedWriter); err != nil { if err = writeFn(bufferedWriter); err != nil {
glog.Errorf("ProcessRangeRequest: %v", err) glog.Errorf("ProcessRangeRequest: %v", err)
w.Header().Del("Content-Length")
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return fmt.Errorf("ProcessRangeRequest: %v", err) return fmt.Errorf("ProcessRangeRequest: %v", err)
} }
@ -351,6 +353,7 @@ func ProcessRangeRequest(r *http.Request, w http.ResponseWriter, totalSize int64
writeFn, err := prepareWriteFn(ra.start, ra.length) writeFn, err := prepareWriteFn(ra.start, ra.length)
if err != nil { if err != nil {
glog.Errorf("ProcessRangeRequest range[0]: %+v err: %v", w.Header(), err) glog.Errorf("ProcessRangeRequest range[0]: %+v err: %v", w.Header(), err)
w.Header().Del("Content-Length")
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return fmt.Errorf("ProcessRangeRequest: %v", err) return fmt.Errorf("ProcessRangeRequest: %v", err)
} }
@ -358,6 +361,7 @@ func ProcessRangeRequest(r *http.Request, w http.ResponseWriter, totalSize int64
err = writeFn(bufferedWriter) err = writeFn(bufferedWriter)
if err != nil { if err != nil {
glog.Errorf("ProcessRangeRequest range[0]: %+v err: %v", w.Header(), err) glog.Errorf("ProcessRangeRequest range[0]: %+v err: %v", w.Header(), err)
w.Header().Del("Content-Length")
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return fmt.Errorf("ProcessRangeRequest range[0]: %v", err) return fmt.Errorf("ProcessRangeRequest range[0]: %v", err)
} }

Loading…
Cancel
Save