rs / zerolog

Zero Allocation JSON Logger
MIT License
10.39k stars 566 forks source link

hlog: Don't write StatusOK header for websockets #611

Closed rschmied closed 10 months ago

rschmied commented 10 months ago

When logging requests and the request is a websocket and the websocket is not properly closed (e.g. the client reloads the page, disconnecting the socket), then hlog tries to write http.StatusOK via WriteHeader() to the hijacked connection which fails as described here

https://stackoverflow.com/questions/32657603/why-do-i-get-the-error-message-http-response-write-on-hijacked-connection

This PR addresses this problem by passing a flag into the WrapWriter() func to indicate whether the request is a Websocket. In this case, the WriteHeader() is suppressed.

rschmied commented 10 months ago

closing as not applicatble.