diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-05-05 15:11:39 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-05-05 15:11:39 -0700 |
| commit | ac71117ee67b0506ecf9fab382d6110e30c50e35 (patch) | |
| tree | c1c79893492f4fb1120e582f40e5779a3761cf24 /weed/server/common.go | |
| parent | 24efa31e49aea0ff5e0cbdaa1a8cb6267dbcbfed (diff) | |
| download | seaweedfs-ac71117ee67b0506ecf9fab382d6110e30c50e35.tar.xz seaweedfs-ac71117ee67b0506ecf9fab382d6110e30c50e35.zip | |
revert PR #1903 avoid http error: superfluous response.WriteHeader
Diffstat (limited to 'weed/server/common.go')
| -rw-r--r-- | weed/server/common.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/weed/server/common.go b/weed/server/common.go index 5c5f1b8eb..9001a3b33 100644 --- a/weed/server/common.go +++ b/weed/server/common.go @@ -234,12 +234,12 @@ func adjustHeaderContentDisposition(w http.ResponseWriter, r *http.Request, file } } -func processRangeRequest(r *http.Request, w http.ResponseWriter, totalSize int64, mimeType string, writeFn func(writer io.Writer, offset int64, size int64) error) { +func processRangeRequest(r *http.Request, w http.ResponseWriter, totalSize int64, mimeType string, writeFn func(writer io.Writer, offset int64, size int64, httpStatusCode int) error) { rangeReq := r.Header.Get("Range") if rangeReq == "" { w.Header().Set("Content-Length", strconv.FormatInt(totalSize, 10)) - if err := writeFn(w, 0, totalSize); err != nil { + if err := writeFn(w, 0, totalSize, 0); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -279,7 +279,7 @@ func processRangeRequest(r *http.Request, w http.ResponseWriter, totalSize int64 w.Header().Set("Content-Length", strconv.FormatInt(ra.length, 10)) w.Header().Set("Content-Range", ra.contentRange(totalSize)) - err = writeFn(w, ra.start, ra.length) + err = writeFn(w, ra.start, ra.length, http.StatusPartialContent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -307,7 +307,7 @@ func processRangeRequest(r *http.Request, w http.ResponseWriter, totalSize int64 pw.CloseWithError(e) return } - if e = writeFn(part, ra.start, ra.length); e != nil { + if e = writeFn(part, ra.start, ra.length, 0); e != nil { pw.CloseWithError(e) return } |
