New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add websocket.Upgrader option. #62
Conversation
thanks for the PR @wavded . The PR looks good and I see the upgrader has more knobs to configure websocket, so it looks like we could extract entire upgrader into options. The DefaultOptions could just use Upgrader with default buffer values just to be sure we keep defaults untouched. |
That seems to be the most flexible option, I went ahead and changed it. Does that match what you had in mind @igm ? |
Yes, this is what I had in mind. My only concern is the buffer size variables ( I suggest small changes to keep those vars in action and at the same time provide upgrader as option flag. What do you think? Review status: all files reviewed at latest revision, all discussions resolved. sockjs/handler.go, line 24 at r2 (raw file):
upgrader is accessible via options, we can omit this field sockjs/handler.go, line 42 at r2 (raw file):
same as above sockjs/options.go, line 45 at r2 (raw file):
sockjs/options.go, line 69 at r2 (raw file):
sockjs/rawwebsocket.go, line 11 at r2 (raw file):
I also suggest something like this: var conn *websocket.Conn
var err error
if h.opts.WebsocketUpgrader!=nil {
conn, err = h.opts.WebsocketUpgrader.Upgrade(rw, req, nil)
} else {
// use default as before, so that those 2 buffer size variables are used as before
conn, err = websocket.Upgrade(rw, req, nil, WebSocketReadBufSize, WebSocketWriteBufSize)
} sockjs/websocket.go, line 17 at r2 (raw file):
Even though I am not happy with these public vars, we should keep them to preserve previous functionality. sockjs/websocket.go, line 20 at r2 (raw file):
same Comments from Reviewable |
Thanks for the feedback @igm. I have that integrated those suggestions and added some additional coverage. |
Review status: all files reviewed at latest revision, all discussions resolved. Comments from Reviewable |
This pull request adds a new option
WebsocketCompression
that when used will allow supported clients to receive and send compressed messages. This is a minimal approach that should be backwards compatible with the current implementation.It takes cues from some prior art:
#56 (Switches to use
websocket.Updater
but made several other changes)#53 (Enabled compression always rather than made it configurable)
This change is