You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Response.Flush does not mark the response as committed #3240
echo.Response.Flush calls the underlying writer's Flush without going through Response.WriteHeader first. If nothing has been written yet, net/http sends an implicit 200 OK and the headers, but Response.Committed stays false. Three things go wrong after that:
A later Write calls WriteHeader again, and net/http logs http: superfluous response.WriteHeader call.
Before hooks run after the headers are already on the wire, so any headers they add are lost.
If the handler then returns an error, DefaultHTTPErrorHandler thinks the response is uncommitted and writes an error body under the 200 that was already sent.
The client gets 200 followed by {"message":"Bad Request"}, and the request logger records the wrong status.
Expected
When the response isn't committed yet, Flush should commit it through WriteHeader with the current status (default 200). That way Before hooks run and Committed is accurate.
Activity