anchor.diff:  		message_parsing_error ->
   			<<"{\"ws_error\": \"Protocol message parsing error\"}">>;
   		_ ->
  -			{RequestMethod, Path, QueryString, ServerName, ServerPort} = Handler:request_info_for_message(ProtocolMessage),
  +			{RequestMethod, Path, QueryString, ServerName, ServerPort} = Handler:request_info_for_message(ProtocolMessage, HandlerState),
   			{ok, {Status, Headers, Body}} = perform_rack_request(RequestMethod, Path, QueryString, ServerName, ServerPort, ServerPath),
  -			Handler:encode_rack_response(Status, Headers, Body)
  +			Handler:encode_rack_response(Status, Headers, Body, HandlerState)
   	end,
  -	WSResponse = Handler:encode_transport_response(Response, ProtocolMessage),
  +	WSResponse = Handler:encode_transport_response(Response, ProtocolMessage, HandlerState),
       {reply, {text, WSResponse}, Req, State};
   
   websocket_handle(_Data, Req, State) ->
  
positive.code: -record(state, {
    	path,
    	handler,
      ws_handler_pid
  }).
  
  %%% Gen_event behaviour methods
  
negative.code: init({tcp, http}, _Req, _Options) ->
    {upgrade, protocol, cowboy_websocket}.
  
  websocket_init(TransportName, Req, Options) ->
  	Path = proplists:get_value(path, Options, "./priv"),
  	Handler = proplists:get_value(handler, Options),
    EventManager = proplists:get_value(event_manager, Options, undefined),
    
    % on connect handler call
    HandlerState = Handler:on_connect(TransportName, Req, Options),
  
    State = #state{path = Path, handler = Handler, ws_handler_pid = self(), ws_handler_state = HandlerState},
    case EventManager of
      undefined -> ok;
      _ -> 
  