anchor.diff:  		Utf8State ->
   			websocket_payload_loop(State2#state{utf8_state=Utf8State},
   				Req, HandlerState, Opcode, Len - byte_size(Data), MaskKey,
  -				<< Unmasked/binary, Unmasked3/binary >>, Rsv)
  +				<< Unmasked/binary, Unmasked3/binary >>,
  +				UnmaskedLen + byte_size(Data), Rsv)
   	end;
   websocket_payload(State=#state{utf8_state=Incomplete},
  -		Req, HandlerState, Opcode, Len, MaskKey, Unmasked, Data, Rsv)
  +		Req, HandlerState, Opcode, Len, MaskKey, Unmasked, UnmaskedLen,
  +		Data, Rsv)
   		when Opcode =:= 1; (Opcode =:= 8) and (Unmasked =/= <<>>) ->
   	<< End:Len/binary, Rest/bits >> = Data,
   	Unmasked2 = websocket_unmask(End,
  -		rotate_mask_key(MaskKey, byte_size(Unmasked)), <<>>),
  +		rotate_mask_key(MaskKey, UnmaskedLen), <<>>),
   	{Unmasked3, State2} = websocket_inflate_frame(Unmasked2, Rsv, true, State),
   	case is_utf8(<< Incomplete/binary, Unmasked3/binary >>) of
   		<<>> ->
  
positive.code: websocket_data(State=#state{frag_state=undefined}, Req, HandlerState,
  		Opcode, Len, MaskKey, Data, Rsv, 0) ->
  	websocket_payload(State#state{frag_state={nofin, Opcode, <<>>}},
  		Req, HandlerState, 0, Len, MaskKey, <<>>, Data, Rsv);
  %% Subsequent frame fragments.
  websocket_data(State=#state{frag_state={nofin, _, _}}, Req, HandlerState,
  		0, Len, MaskKey, Data, Rsv, 0) ->
  	websocket_payload(State, Req, HandlerState,
  		0, Len, MaskKey, <<>>, Data, Rsv);
  %% Final frame fragment.
  websocket_data(State=#state{frag_state={nofin, Opcode, SoFar}},
  		Req, HandlerState, 0, Len, MaskKey, Data, Rsv, 1) ->
  	websocket_payload(State#state{frag_state={fin, Opcode, SoFar}},
  		Req, HandlerState, 0, Len, MaskKey, <<>>, Data, Rsv);
  %% Unfragmented frame.
  websocket_data(State, Req, HandlerState, Opcode, Len, MaskKey, Data, Rsv, 1) ->
  	websocket_payload(State, Req, HandlerState,
  		Opcode, Len, MaskKey, <<>>, Data, Rsv).
  
  -spec websocket_payload(#state{}, Req, any(),
  	opcode(), non_neg_integer(), mask_key(), binary(), binary(), rsv())
  	-> {ok, Req, cowboy_middleware:env()}
  	| {suspend, module(), atom(), [any()]}
  	when Req::cowboy_req:req().
  %% Close control frames with a payload MUST contain a valid close code.
  websocket_payload(State, Req, HandlerState,
  		Opcode=8, Len, MaskKey, <<>>, << MaskedCode:2/binary, Rest/bits >>, Rsv) ->
  	Unmasked = << Code:16 >> = websocket_unmask(MaskedCode, MaskKey, <<>>),
  	if	Code < 1000; Code =:= 1004; Code =:= 1005; Code =:= 1006;
  				(Code > 1011) and (Code < 3000); Code > 4999 ->
  			websocket_close(State, Req, HandlerState, {error, badframe});
  		true ->
  			websocket_payload(State, Req, HandlerState,
  				Opcode, Len - 2, MaskKey, Unmasked, Rest, Rsv)
  	end;
  %% Text frames and close control frames MUST have a payload that is valid UTF-8.
  websocket_payload(State=#state{utf8_state=Incomplete},
  		Req, HandlerState, Opcode, Len, MaskKey, Unmasked, Data, Rsv)
  		when (byte_size(Data) < Len) andalso ((Opcode =:= 1) orelse
  			((Opcode =:= 8) andalso (Unmasked =/= <<>>))) ->
  	Unmasked2 = websocket_unmask(Data,
  		rotate_mask_key(MaskKey, byte_size(Unmasked)), <<>>),
  	{Unmasked3, State2} = websocket_inflate_frame(Unmasked2, Rsv, false, State),
  	case is_utf8(<< Incomplete/binary, Unmasked3/binary >>) of
  		false ->
  
negative.code: 	end;
  %% Fragmented text frames may cut payload in the middle of UTF-8 codepoints.
  websocket_payload(State=#state{frag_state={_, 1, _}, utf8_state=Incomplete},
  		Req, HandlerState, Opcode=0, Len, MaskKey, Unmasked, UnmaskedLen,
  		Data, Rsv)
  		when byte_size(Data) < Len ->
  	Unmasked2 = websocket_unmask(Data,
  		rotate_mask_key(MaskKey, UnmaskedLen), <<>>),
  	{Unmasked3, State2} = websocket_inflate_frame(Unmasked2, Rsv, false, State),
  	case is_utf8(<< Incomplete/binary, Unmasked3/binary >>) of
  		false ->
  