mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 14:13:48 +03:00
caddyhttp: Write header if needed in responseRecorder.WriteResponse (#6380)
This commit is contained in:
parent
a10117f8bd
commit
9be4f194e0
1 changed files with 4 additions and 4 deletions
|
@ -219,13 +219,13 @@ func (rr *responseRecorder) Buffered() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rr *responseRecorder) WriteResponse() error {
|
func (rr *responseRecorder) WriteResponse() error {
|
||||||
if rr.stream {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if rr.statusCode == 0 {
|
if rr.statusCode == 0 {
|
||||||
// could happen if no handlers actually wrote anything,
|
// could happen if no handlers actually wrote anything,
|
||||||
// and this prevents a panic; status must be > 0
|
// and this prevents a panic; status must be > 0
|
||||||
rr.statusCode = http.StatusOK
|
rr.WriteHeader(http.StatusOK)
|
||||||
|
}
|
||||||
|
if rr.stream {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
rr.ResponseWriterWrapper.WriteHeader(rr.statusCode)
|
rr.ResponseWriterWrapper.WriteHeader(rr.statusCode)
|
||||||
_, err := io.Copy(rr.ResponseWriterWrapper, rr.buf)
|
_, err := io.Copy(rr.ResponseWriterWrapper, rr.buf)
|
||||||
|
|
Loading…
Reference in a new issue