anchor.diff:  -ifdef(TEST).
   
   header_find_test() ->
  -  json = find_supported_protocol([?WSJSON_BATCHED,?WSJSON]).
  +  {json,?WSJSON} = find_supported_protocol([?WSJSON_BATCHED,?WSJSON]).
   
   
   -endif.
  
positive.code:   {ok,State#state{router=NewRouter,buffer=NewBuffer}}.
  
  
  find_supported_protocol([]) ->
    unsupported;
  find_supported_protocol([?WSJSON|_T]) ->
    json;
  find_supported_protocol([?WSMSGPACK|_T]) ->
    msgpack;
  find_supported_protocol([_|T]) ->
    find_supported_protocol(T).
  
  
negative.code:   % need to check for the wamp.2.json or wamp.2.msgpack
    {ok, Protocols, Req1} = cowboy_req:parse_header(?SUBPROTHEADER, Req),
    case find_supported_protocol(Protocols) of
        {Enc,Header} ->
          Req2  = cowboy_req:set_resp_header(?SUBPROTHEADER,Header,Req1),
          {ok,Req2,#state{enc=Enc}};
        _ ->
          % unsupported
          {shutdown,Req1}
    end.
  
  
  