(w http.ResponseWriter)
| 501 | } |
| 502 | |
| 503 | func (t *timeoutResponseWriter) finallyWrite(w http.ResponseWriter) { |
| 504 | t.Lock() |
| 505 | defer t.Unlock() |
| 506 | |
| 507 | dst := w.Header() |
| 508 | for k, vv := range t.snapHeader { |
| 509 | dst[k] = vv |
| 510 | } |
| 511 | |
| 512 | if !t.wroteHeader { |
| 513 | t.statusCode = http.StatusOK |
| 514 | } |
| 515 | |
| 516 | w.WriteHeader(t.statusCode) |
| 517 | if _, err := w.Write(t.buf.Bytes()); err != nil { |
| 518 | logrus.WithError(err).Warn("Write failed") |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | // limitRequestBody wraps the request body with http.MaxBytesReader to prevent |
| 523 | // memory exhaustion from excessively large request bodies (gosec G120). |
no test coverage detected