Permalink
Browse files

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.
  • Loading branch information...
1 parent c2be0f2 commit 97460a599377eab084ffe99588b2c24bab23c27d Loïc Hoguin committed Oct 5, 2011
Showing with 3 additions and 2 deletions.
  1. +1 −1 src/cowboy_http_req.erl
  2. +2 −1 test/websocket_handler.erl
View
@@ -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};

0 comments on commit 97460a5

Please sign in to comment.