forked from TrueCloudLab/frostfs-s3-gw
Fix NPE when response isn't http.Flusher
Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
This commit is contained in:
parent
54a03d3689
commit
54414c2bfb
1 changed files with 7 additions and 3 deletions
|
@ -175,9 +175,13 @@ func WriteResponse(w http.ResponseWriter, statusCode int, response []byte, mType
|
|||
}
|
||||
w.Header().Set(hdrContentLength, strconv.Itoa(len(response)))
|
||||
w.WriteHeader(statusCode)
|
||||
if response != nil {
|
||||
_, _ = w.Write(response)
|
||||
w.(http.Flusher).Flush()
|
||||
if response == nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, _ = w.Write(response)
|
||||
if flusher, ok := w.(http.Flusher); ok {
|
||||
flusher.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue