mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Fix a crash in websocket_handshake when cowboy_http_req:compact/1 is used
Also add a call to compact/1 in the websocket test handler so we may catch bugs related to it faster later on.
This commit is contained in:
parent
c2be0f2073
commit
97460a5993
2 changed files with 3 additions and 2 deletions
|
@ -366,7 +366,7 @@ chunk(Data, #http_req{socket=Socket, transport=Transport, resp_state=chunks}) ->
|
|||
-spec compact(#http_req{}) -> #http_req{}.
|
||||
compact(Req) ->
|
||||
Req#http_req{host=undefined, host_info=undefined, path=undefined,
|
||||
path_info=undefined, qs_vals=undefined, raw_qs=undefined,
|
||||
path_info=undefined, qs_vals=undefined,
|
||||
bindings=undefined, headers=[]}.
|
||||
|
||||
%% Internal.
|
||||
|
|
|
@ -18,7 +18,8 @@ terminate(_Req, _State) ->
|
|||
|
||||
websocket_init(_TransportName, Req, _Opts) ->
|
||||
erlang:start_timer(1000, self(), <<"websocket_init">>),
|
||||
{ok, Req, undefined}.
|
||||
Req2 = cowboy_http_req:compact(Req),
|
||||
{ok, Req2, undefined}.
|
||||
|
||||
websocket_handle({text, Data}, Req, State) ->
|
||||
{reply, {text, Data}, Req, State};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue