[WebSocket]Browser must fail connection if Sec-WebSocket-Protocol mismatched.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2012 04:22:12 +0000 (04:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2012 04:22:12 +0000 (04:22 +0000)
commit1004ed81df2b0075fc05dcd30259b22392164359
treee68b4611aab70db57118988a791cd2a822276553
parentdc1d6120386ccc6a168b51047545f069ebcc77b2
[WebSocket]Browser must fail connection if Sec-WebSocket-Protocol mismatched.
https://bugs.webkit.org/show_bug.cgi?id=82307

Patch by Li Yin <li.yin@intel.com> on 2012-03-28
Reviewed by Kent Tamura.

Source/WebCore:

From RFC6455: http://tools.ietf.org/html/rfc6455#section-4.1
If the WebSocket openhanding respond included the mismatched
Sec-WebSocket-Protocol header field, the client must fail the WebSocket Connection.

Test: http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header.html

* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::checkResponseHeaders):

LayoutTests:

From RFC6455: http://tools.ietf.org/html/rfc6455#section-4.1
If the response includes a |Sec-WebSocket-Protocol| header field
and this header field indicates the use of a subprotocol that was
not present in the client's handshake (the server has indicated a
subprotocol not requested by the client), the client MUST _Fail
the WebSocket Connection_.

* http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header-expected.txt: Added.
* http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header.html: Added.
* http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header_wsh.py: Added.
(web_socket_do_extra_handshake):
(web_socket_transfer_data):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112499 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header.html [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header_wsh.py [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/Modules/websockets/WebSocket.h
Source/WebCore/Modules/websockets/WebSocketHandshake.cpp