Tcl Library Source Code

View Ticket
Login
Ticket UUID: e23279c7d123395348b0660ec0016afcffcce1d3
Title: Websocket: empty protocol list throws error
Type: Bug Version: 1.4
Submitter: anonymous Created on: 2015-06-15 17:19:55
Subsystem: websocket Assigned To: emmanuel
Priority: 5 Medium Severity: Important
Status: Open Last Modified: 2015-06-15 17:47:08
Resolution: None Closed By: nobody
    Closed on:
Description:
Requesting a websocket with no protocols specified causes ::websocket::test to throw an error.
For example, in Firefox v.38, the following javascript code is used to create the websocket:
websock = new WebSocket("wss://example.com/websock")
(There is an optional protocols argument following the first argument, but it is optional.)
In my tclhttpd setup, the headers do not have a field for sec-websocket-protocol. This causes ::websocket::validate to return a dictionary that has no protocols field. In websocket::test, the line
set protos [dict get $res protocols];
then throws an error.
My first workaround was to change the javascript code to specify the protocol. A better workaround is to change the line in websocket::test to catch the error and assign "*" to the variable protos in the event of an error. In other words, specifying no protocols implies all protocols are acceptable.