aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-04-20 12:47:59 +0200
committerLoïc Hoguin <[email protected].eu>2020-04-20 12:47:59 +0200
commit1949f034eae142306c97510432ab0952754a25d8 (patch)
treedf24cf7c3a916c2d87ed0defb55ccb872f4b3162
parent422fb08d111068fd8ca35150d7b2c49b48f940b5 (diff)
downloadcowlib-struct-hd-15.tar.gz
cowlib-struct-hd-15.tar.bz2
cowlib-struct-hd-15.zip
Fix structured header tests added up until nowstruct-hd-15
-rw-r--r--src/cow_http_struct_hd.erl14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/cow_http_struct_hd.erl b/src/cow_http_struct_hd.erl
index 4138929..39897b2 100644
--- a/src/cow_http_struct_hd.erl
+++ b/src/cow_http_struct_hd.erl
@@ -62,24 +62,24 @@
-spec parse_dictionary(binary()) -> sh_dictionary().
parse_dictionary(<<>>) ->
{#{}, []};
-parse_dictionary(<<C,R/bits>>) when ?IS_LC_ALPHA(C) ->
+parse_dictionary(<<C,R/bits>>) when ?IS_LC_ALPHA(C) or (C =:= $*) ->
{Dict, Order, <<>>} = parse_dict_key(R, #{}, [], <<C>>),
{Dict, Order}.
parse_dict_key(<<$=,$(,R0/bits>>, Acc, Order, K) ->
- false = maps:is_key(K, Acc),
{Item, R} = parse_inner_list(R0, []),
parse_dict_before_sep(R, Acc#{K => Item}, [K|Order]);
parse_dict_key(<<$=,R0/bits>>, Acc, Order, K) ->
- false = maps:is_key(K, Acc),
{Item, R} = parse_item1(R0),
parse_dict_before_sep(R, Acc#{K => Item}, [K|Order]);
parse_dict_key(<<C,R/bits>>, Acc, Order, K)
when ?IS_LC_ALPHA(C) or ?IS_DIGIT(C)
or (C =:= $_) or (C =:= $-) or (C =:= $.) or (C =:= $*) ->
parse_dict_key(R, Acc, Order, <<K/binary,C>>);
+parse_dict_key(<<$;,R0/bits>>, Acc, Order, K) ->
+ {Params, R} = parse_before_param(R0, #{}),
+ parse_dict_before_sep(R, Acc#{K => {with_params, true, Params}}, [K|Order]);
parse_dict_key(R, Acc, Order, K) ->
- false = maps:is_key(K, Acc),
parse_dict_before_sep(R, Acc#{K => {with_params, true, #{}}}, [K|Order]).
parse_dict_before_sep(<<$\s,R/bits>>, Acc, Order) ->
@@ -91,7 +91,7 @@ parse_dict_before_sep(<<>>, Acc, Order) ->
parse_dict_before_member(<<$\s,R/bits>>, Acc, Order) ->
parse_dict_before_member(R, Acc, Order);
-parse_dict_before_member(<<C,R/bits>>, Acc, Order) when ?IS_LC_ALPHA(C) ->
+parse_dict_before_member(<<C,R/bits>>, Acc, Order) when ?IS_LC_ALPHA(C) or (C =:= $*) ->
parse_dict_key(R, Acc, Order, <<C>>).
-spec parse_item(binary()) -> sh_item().
@@ -149,7 +149,7 @@ parse_inner_list(R0, Acc) ->
parse_before_param(<<$\s,R/bits>>, Acc) ->
parse_before_param(R, Acc);
-parse_before_param(<<C,R/bits>>, Acc) when ?IS_LC_ALPHA(C) ->
+parse_before_param(<<C,R/bits>>, Acc) when ?IS_LC_ALPHA(C) or (C =:= $*) ->
parse_param(R, Acc, <<C>>).
parse_param(<<$;,R/bits>>, Acc, K) ->
@@ -158,10 +158,8 @@ parse_param(<<$;,R/bits>>, Acc, K) ->
parse_param(<<$=,R0/bits>>, Acc, K) ->
case parse_bare_item(R0) of
{Item, <<$;,R/bits>>} ->
- false = maps:is_key(K, Acc),
parse_before_param(R, Acc#{K => Item});
{Item, R} ->
- false = maps:is_key(K, Acc),
{Acc#{K => Item}, R}
end;
parse_param(<<C,R/bits>>, Acc, K)