diff --git a/lib/headers.ml b/lib/headers.ml index 6c5320ca..ff6fce01 100644 --- a/lib/headers.ml +++ b/lib/headers.ml @@ -95,9 +95,9 @@ let replace t name value = if CI.equal needle name then ( if seen - then loop t name nv true - else nv::loop t name nv true) - else nv'::loop t name nv seen + then loop t needle nv true + else nv::loop t needle nv true) + else nv'::loop t needle nv seen in try loop t name (name,value) false with Local -> t diff --git a/lib_test/test_httpaf.ml b/lib_test/test_httpaf.ml index 223e586c..333565b9 100644 --- a/lib_test/test_httpaf.ml +++ b/lib_test/test_httpaf.ml @@ -126,6 +126,13 @@ module Headers = struct "a" "d"); + check "replace middle element" + ~expect:["e", "f"; "c", "z"; "a", "b"] + (Headers.replace + (Headers.of_list ["e", "f"; "c", "d"; "a", "b"]) + "c" + "z"); + check "remove multiple trailing elements" ~expect:["c", "d"; "a", "d"] (Headers.replace @@ -994,7 +1001,7 @@ module Client_connection = struct let tests = [ "GET" , `Quick, test_get ; "Response EOF", `Quick, test_response_eof - ; "report_exn" , `Quick, test_report_exn + ; "report_exn" , `Quick, test_report_exn ; "input_shrunk", `Quick, test_input_shrunk ] end