CC: Tweaked

CC: Tweaked

57M Downloads

Unable to specify websocket subprotocol

MDMCK10 opened this issue ยท 0 comments

commented

Useful information to include:

  • Minecraft version 1.16.5
  • CC: Tweaked version 1.16.4-1.96.0
  • Logs: These will be located in the logs/ directory of your Minecraft instance. Please upload them as a gist or directly into this editor. not relevant to issue
  • Detailed reproduction steps: sometimes I can spot a bug pretty easily, but often it's much more obscure. The more information I have to help reproduce it, the quicker it'll get fixed.

Trying to set the Sec-WebSocket-Protocol header results in the following error:
Invalid subprotocol. Actual: [subprotocol name]. Expected one of: null
The following code can be used reproduce the issue:

local ws, err = http.websocket("ws://computernewb.com:6004", {["Sec-WebSocket-Protocol"]="guacamole"})
if not ws then
  return printError(err)
end

The reason this happens is because in this part of the source code, null is being passed as the third (subprotocol) parameter for WebSocketClientHandshakerFactory.newHandshaker.

Fixing this would require adding a way for the user to specify this, perhaps in a third parameter to http.websocket (maybe http.websocket("ws://server.here", {}, "subprotocol here")?)