Revert "revert PR #1903 avoid http error: superfluous response.WriteHeader"

This reverts commit ac71117e
This commit is contained in:
Konstantin Lebedev
2021-05-20 11:45:21 +05:00
parent 87a32bfef4
commit 03d1199d5f
9 changed files with 45 additions and 20 deletions

View File

@@ -326,7 +326,11 @@ func passThroughResponse(proxyResponse *http.Response, w http.ResponseWriter) {
for k, v := range proxyResponse.Header {
w.Header()[k] = v
}
w.WriteHeader(proxyResponse.StatusCode)
if proxyResponse.Header.Get("Content-Range") != "" && proxyResponse.StatusCode == 200 {
w.WriteHeader(http.StatusPartialContent)
} else {
w.WriteHeader(proxyResponse.StatusCode)
}
io.Copy(w, proxyResponse.Body)
}