Browse Source

Add a property for cow_http_hd:parse_transfer_encoding/1

Loïc Hoguin 10 years ago
parent
commit
a5c1a88378
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/cow_http_hd.erl

+ 11 - 1
src/cow_http_hd.erl

@@ -1037,7 +1037,7 @@ parse_max_forwards_error_test_() ->
 
 %% @doc Parse the Transfer-Encoding header.
 %%
-%% @todo Extension parameters.
+%% @todo This function does not support parsing of transfer-parameter.
 
 -spec parse_transfer_encoding(binary()) -> [binary()].
 parse_transfer_encoding(<<"chunked">>) ->
@@ -1046,6 +1046,16 @@ parse_transfer_encoding(TransferEncoding) ->
 	nonempty(token_ci_list(TransferEncoding, [])).
 
 -ifdef(TEST).
+prop_parse_transfer_encoding() ->
+	?FORALL(L,
+		non_empty(list(token())),
+		begin
+			<< _, TransferEncoding/binary >> = iolist_to_binary([[$,, C] || C <- L]),
+			ResL = parse_transfer_encoding(TransferEncoding),
+			CheckedL = [?INLINE_LOWERCASE_BC(Co) =:= ResC || {Co, ResC} <- lists:zip(L, ResL)],
+			[true] =:= lists:usort(CheckedL)
+		end).
+
 parse_transfer_encoding_test_() ->
 	Tests = [
 		{<<"a , , , ">>, [<<"a">>]},