anchor.diff:                   _ when is_integer(Reason) -> Reason;
                    _ -> ?NORMAL_WS_STATUS
                end,
  -    send(WSState, {close, <<Status:16/big>>}),
  -    exit(Reason).
  +    do_send(WSState, {close, <<Status:16/big>>}).
   
   basic_messages(FrameInfos, {FragType, FragAcc}) ->
  -    {Messages, NewFragType, NewFragAcc}
  -        = lists:foldl(fun handle_message/2, {[], FragType, FragAcc}, FrameInfos),
  +    {Messages, NewFragType, NewFragAcc} =
  +        lists:foldl(fun handle_message/2, {[], FragType, FragAcc}, FrameInfos),
       {Messages, {NewFragType, NewFragAcc}}.
   
   %% start of a fragmented message
  
positive.code:                                 {advanced, InitialState} ->
                                      InitialState
                              end,
              loop(CallbackMod, WSState, CallbackState, CallbackType)
      end.
  
  origin_check(_Origin, {origin, any}) ->
      ok;
  
negative.code:      "Sec-WebSocket-Accept: ", AcceptHash , "\r\n",
       "\r\n"].
  
  handle_result_fun(WSState) ->
      fun(Result, Acc) ->
              case Result of
                  {reply, {Type, Data}} ->
                      do_send(WSState, {Type, Data}),
                      Acc;
                  noreply ->
                      Acc;
                  {close, Reason} ->
                      throw({close, Reason})
              end
      end.
  
  do_callback_fun(WSState, CallbackMod) ->
      fun(FrameInfo, {Results, CallbackState}) ->
              case CallbackMod:handle_message(FrameInfo, CallbackState) of
                  {reply, {Type, Data}, NewCallbackState} ->
                      do_send(WSState, {Type, Data}),
                      {Results, NewCallbackState};
                  {noreply, NewCallbackState} ->
                      {Results, NewCallbackState};
                  {close, Reason} ->
                      throw({{close, Reason}, CallbackState})
              end
      end.
  
  