From 30c3c75bbcbbf36c2b82ede0a723f4271e05e510 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Mon, 24 Oct 2011 15:06:51 +0100 Subject: Accept Sec-WebSocket-Version: 13 header on Chrome 15 through 17 --- src/cowboy_http_websocket.erl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/cowboy_http_websocket.erl') diff --git a/src/cowboy_http_websocket.erl b/src/cowboy_http_websocket.erl index 1111b96..a061ad0 100644 --- a/src/cowboy_http_websocket.erl +++ b/src/cowboy_http_websocket.erl @@ -103,13 +103,15 @@ websocket_upgrade(undefined, State, Req) -> EOP = binary:compile_pattern(<< 255 >>), {ok, State#state{version=0, origin=Origin, challenge={Key1, Key2}, eop=EOP}, Req4}; -%% Versions 7 and 8. Implementation follows the hybi 7 through 10 drafts. -websocket_upgrade(<< Version >>, State, Req) - when Version =:= $7; Version =:= $8 -> +%% Versions 7 and 8. Implementation follows the hybi 7 through 17 drafts. +websocket_upgrade(Version, State, Req) + when Version =:= <<"7">>; Version =:= <<"8">>; + Version =:= <<"13">> -> {Key, Req2} = cowboy_http_req:header(<<"Sec-Websocket-Key">>, Req), false = Key =:= undefined, Challenge = hybi_challenge(Key), - {ok, State#state{version=Version - $0, challenge=Challenge}, Req2}. + IntVersion = list_to_integer(binary_to_list(Version)), + {ok, State#state{version=IntVersion, challenge=Challenge}, Req2}. -spec handler_init(#state{}, #http_req{}) -> ok | none(). handler_init(State=#state{handler=Handler, opts=Opts}, -- cgit v1.2.3