-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
Currently (1.13) calling Flush
on a ResponseWriter
exposed by TimeoutHandler
has some undesirable effect:
- it sends out default headers with a
200 OK
status, ignoring whatever the caller set before (e.g.w.Header().Set(key, val)
orw.WriteHeader(someOtherCode)
); - in doing so, it prevents
TimeoutHandler
to respond with503
on timeout as promised, and it produces a"superfluous response.WriteHeader call"
warning; - it doesn't flush anything.
https://play.golang.org/p/HmW2ETipalB
This is happening because timeoutWriter.Flush
calls the underlying Flush
, which in turn calls the underlying WriteHeader
from a clean state: the actual header and partial body are still buffered in the wrapper (in timeoutWriter.h
and timeoutWriter.wbuf
).
I think TimeoutHandler
supporting Flush
doesn't make any sense because a TimeoutHandler
doesn't know what to do until either the inner handler returns or the timeout is reached, therefore it needs to buffer the whole response until the end.
EDIT: #34198 is probably an effect.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.