scs icon indicating copy to clipboard operation
scs copied to clipboard

*scs.sessionResponseWriter does not implement http.Hijacker

Open NewHouses opened this issue 2 years ago • 3 comments

Hey there! 👋 It seems like we've hit a small roadblock with the scs.sessionResponseWriter wrapper for http.response. Currently, it doesn't implement the http.Hijacker interface. So, when attempting to open a WebSocket, you might encounter the error message: websocket: response does not implement http.Hijacker.

In the past, it were using *scs.bufferedResponseWriter, which conveniently does implement the Hijacker interface.

NewHouses avatar Nov 28 '23 21:11 NewHouses

@alexedwards would you kindly accept pull request with a fix to this error?

wosienko avatar Feb 03 '24 14:02 wosienko

I think that the correct fix here is really for the websocket library to start supporting http.ResponseController, which is the modern way of dealing with this.

I've pushed https://github.com/alexedwards/scs/commit/a38e822451b69071afa6fd12667d50df4563d20f which makes sessionResponseWriter implement the Hijacker and Flusher interfaces for Go 1.20+. Please let me know if it solves your problem.

alexedwards avatar Feb 03 '24 17:02 alexedwards

Thank you, works like a charm!

wosienko avatar Feb 12 '24 19:02 wosienko