Browse Source

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.
Loïc Hoguin 13 years ago
parent
commit
97460a5993
2 changed files with 3 additions and 2 deletions
  1. 1 1
      src/cowboy_http_req.erl
  2. 2 1
      test/websocket_handler.erl

+ 1 - 1
src/cowboy_http_req.erl

@@ -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.

+ 2 - 1
test/websocket_handler.erl

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