0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 20:50:24 +00:00

Accept Sec-WebSocket-Version: 13 header on Chrome 15 through 17

This commit is contained in:
Paul Oliver 2011-10-24 15:06:51 +01:00
parent f990109af6
commit 30c3c75bbc
2 changed files with 49 additions and 6 deletions

View file

@ -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},