anchor.diff:  		true -> ok
   	end.
   
  +unmask(Data, undefined, _) ->
  +	Data;
   unmask(Data, MaskKey, 0) ->
  -	do_unmask(Data, MaskKey, <<>>);
  +	mask(Data, MaskKey, <<>>);
   %% We unmask on the fly so we need to continue from the right mask byte.
   unmask(Data, MaskKey, UnmaskedLen) ->
   	Left = UnmaskedLen rem 4,
   	Right = 4 - Left,
   	MaskKey2 = (MaskKey bsl (Left * 8)) + (MaskKey bsr (Right * 8)),
  -	do_unmask(Data, MaskKey2, <<>>).
  -
  -do_unmask(<<>>, _, Unmasked) ->
  +	mask(Data, MaskKey2, <<>>).
  +
  +mask(<<>>, _, Unmasked) ->
   	Unmasked;
  -do_unmask(<< O:32, Rest/bits >>, MaskKey, Acc) ->
  +mask(<< O:32, Rest/bits >>, MaskKey, Acc) ->
   	T = O bxor MaskKey,
  -	do_unmask(Rest, MaskKey, << Acc/binary, T:32 >>);
  -do_unmask(<< O:24 >>, MaskKey, Acc) ->
  +	mask(Rest, MaskKey, << Acc/binary, T:32 >>);
  +mask(<< O:24 >>, MaskKey, Acc) ->
   	<< MaskKey2:24, _:8 >> = << MaskKey:32 >>,
   	T = O bxor MaskKey2,
   	<< Acc/binary, T:24 >>;
  -do_unmask(<< O:16 >>, MaskKey, Acc) ->
  +mask(<< O:16 >>, MaskKey, Acc) ->
   	<< MaskKey2:16, _:16 >> = << MaskKey:32 >>,
   	T = O bxor MaskKey2,
   	<< Acc/binary, T:16 >>;
  -do_unmask(<< O:8 >>, MaskKey, Acc) ->
  +mask(<< O:8 >>, MaskKey, Acc) ->
   	<< MaskKey2:8, _:24 >> = << MaskKey:32 >>,
   	T = O bxor MaskKey2,
   	<< Acc/binary, T:8 >>.
   
  -%% @todo Try using iodata() and see if it improves anything.
   inflate_frame(Data, Inflate, TakeOver, FragState, true)
   		when FragState =:= undefined; element(1, FragState) =:= fin ->
   	Data2 = zlib:inflate(Inflate, << Data/binary, 0, 0, 255, 255 >>),
  
positive.code: 
  -module(cow_ws).
  
  -export([negotiate_permessage_deflate/3]).
  -export([negotiate_x_webkit_deflate_frame/3]).
  
  -export([parse_header/3]).
  -export([parse_payload/9]).
  -export([make_frame/4]).
  -export([frame/2]).
  
  -type close_code() :: 1000..1003 | 1006..1011 | 3000..4999.
  -export_type([close_code/0]).
  
  -type frag_state() :: undefined | {fin | nofin, text | binary, rsv()}.
  -export_type([frag_state/0]).
  
negative.code: 			deflate_takeover => takeover,
  			inflate => Inflate,
  			inflate_takeover => takeover}}.
  
  %% @doc Validate the negotiated permessage-deflate extension.
  
  %% Error when more than one deflate extension was negotiated.
  validate_permessage_deflate(_, #{deflate := _}, _) ->
  	error;
  validate_permessage_deflate(Params, Extensions, Opts) ->
  	case lists:usort(Params) of
  		%% Error if multiple parameters with the same name.
  		Params2 when length(Params) =/= length(Params2) ->
  			error;
  		Params2 ->
  			%% @todo Might want to make some of these configurable defaults if at all possible.
  			case parse_response_permessage_deflate_params(Params2, 15, takeover, 15, takeover) of
  				error ->
  					error;
  				{ClientWindowBits, ClientTakeOver, ServerWindowBits, ServerTakeOver} ->
  					{Inflate, Deflate} = init_permessage_deflate(ServerWindowBits, ClientWindowBits, Opts),
  					{ok, Extensions#{
  						deflate => Deflate,
  						deflate_takeover => ClientTakeOver,
  						inflate => Inflate,
  						inflate_takeover => ServerTakeOver}}
  			end
  	end.
  
  parse_response_permessage_deflate_params([], CB, CTO, SB, STO) ->
  	{CB, CTO, SB, STO};
  parse_response_permessage_deflate_params([{<<"client_max_window_bits">>, Max}|Tail], _, CTO, SB, STO) ->
  	case parse_max_window_bits(Max) of
  		error -> error;
  		CB -> parse_response_permessage_deflate_params(Tail, CB, CTO, SB, STO)
  	end;
  parse_response_permessage_deflate_params([<<"client_no_context_takeover">>|Tail], CB, _, SB, STO) ->
  	parse_response_permessage_deflate_params(Tail, CB, no_takeover, SB, STO);
  parse_response_permessage_deflate_params([{<<"server_max_window_bits">>, Max}|Tail], CB, CTO, _, STO) ->
  	case parse_max_window_bits(Max) of
  		error -> error;
  		SB -> parse_response_permessage_deflate_params(Tail, CB, CTO, SB, STO)
  	end;
  parse_response_permessage_deflate_params([<<"server_no_context_takeover">>|Tail], CB, CTO, SB, _) ->
  	parse_response_permessage_deflate_params(Tail, CB, CTO, SB, no_takeover);
  %% Error if unknown parameter; error if parameter with invalid or missing value.
  parse_response_permessage_deflate_params(_, _, _, _, _) ->
  	error.
  
  %% @doc Parse and validate the Websocket frame header.
  %%
  