ARI: Fix WebSocket response when subprotocol isn't specified
authorDavid M. Lee <dlee@digium.com>
Fri, 13 Sep 2013 14:19:19 +0000 (14:19 +0000)
committerDavid M. Lee <dlee@digium.com>
Fri, 13 Sep 2013 14:19:19 +0000 (14:19 +0000)
commitf56796a5397cc818a5b151a27d808425589a123d
treefe14b0b7084f2717cb2330ac745f4557a1aee131
parent0ffcd11380b1c966ee26b5ea2c319e023bc0cd7f
ARI: Fix WebSocket response when subprotocol isn't specified

When I moved the ARI WebSocket from /ws to /ari/events, I added code to
allow a WebSocket to connect without specifying the subprotocol if
there's only one subprotocol handler registered for the WebSocket.

Naively, I coded it to always respond with the subprotocol in use.
Unfortunately, according to RFC 6455, if the server's response includes
a subprotocol header field that "indicates the use of a subprotocol that
was not present in the client's handshake [...], the client MUST _Fail
the WebSocket Connection_.", emphasis theirs.

This patch correctly omits the Sec-WebSocket-Protocol if one is not
specified by the client.

(closes issue ASTERISK-22441)
Review: https://reviewboard.asterisk.org/r/2828/
........

Merged revisions 399039 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399042 65c4cc65-6c06-0410-ace0-fbb531ad65f3
res/res_http_websocket.c