File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -102,12 +102,14 @@ let replace t name value =
102102 with Local -> t
103103
104104let remove t name =
105- let rec loop s n seen =
105+ let rec loop s needle seen =
106106 match s with
107107 | [] ->
108108 if not seen then raise Local else []
109- | (n' ,_ as nv' )::s' ->
110- if CI. equal n n' then loop s' n true else nv'::(loop s' n false )
109+ | (name ,_ as nv' )::s' ->
110+ if CI. equal needle name
111+ then (print_endline " seen: true" ; loop s' needle true )
112+ else (print_endline " seen: false" ; nv'::(loop s' needle seen))
111113 in
112114 try loop t name false
113115 with Local -> t
Original file line number Diff line number Diff line change @@ -111,6 +111,29 @@ module IOVec = struct
111111 ; " shiftv raises " , `Quick , test_shiftv_raises ]
112112end
113113
114+ module Headers = struct
115+ include Headers
116+
117+ let test_remove () =
118+ let check = Alcotest. (check (list (pair string string ))) in
119+ check " remove leading element"
120+ [" c" , " d" ]
121+ (Headers. remove
122+ (Headers. of_list [" a" , " b" ; " c" , " d" ])
123+ " a"
124+ |> Headers. to_list);
125+ check " remove trailing element"
126+ [" c" , " d" ]
127+ (Headers. remove
128+ (Headers. of_list [" c" , " d" ; " a" , " b" ])
129+ " a"
130+ |> Headers. to_list);
131+ ;;
132+
133+ let tests =
134+ [ " remove" , `Quick , test_remove ]
135+ end
136+
114137let maybe_serialize_body f body =
115138 match body with
116139 | None -> ()
@@ -793,6 +816,7 @@ let () =
793816 [ " version" , Version. tests
794817 ; " method" , Method. tests
795818 ; " iovec" , IOVec. tests
819+ ; " headers" , Headers. tests
796820 ; " client connection" , Client_connection. tests
797821 ; " server connection" , Server_connection. tests
798822 ]
You can’t perform that action at this time.
0 commit comments