forked from TrueCloudLab/frostfs-s3-gw
WriteHeader should be called once
Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
This commit is contained in:
parent
1cd636a24b
commit
697d318a6b
2 changed files with 19 additions and 14 deletions
|
@ -41,11 +41,11 @@ type (
|
|||
}
|
||||
|
||||
responseWrapper struct {
|
||||
sync.Once
|
||||
http.ResponseWriter
|
||||
|
||||
statusCode int
|
||||
headWritten bool
|
||||
startTime time.Time
|
||||
statusCode int
|
||||
startTime time.Time
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -202,12 +202,10 @@ func (st *HTTPStats) updateStats(api string, w http.ResponseWriter, r *http.Requ
|
|||
|
||||
// WriteHeader - writes http status code
|
||||
func (w *responseWrapper) WriteHeader(code int) {
|
||||
if !w.headWritten {
|
||||
w.Do(func() {
|
||||
w.statusCode = code
|
||||
w.headWritten = true
|
||||
|
||||
w.ResponseWriter.WriteHeader(code)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Flush - Calls the underlying Flush.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue