From a9b95abce67f99f295c0692a66934b5b550bc349 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 7 Feb 2015 17:13:08 -0500 Subject: [PATCH] Fix type in post_form type of params is (string * string list) list and not Header.t --- js/cohttp_lwt_xhr.ml | 3 +-- lwt/cohttp_lwt.ml | 5 ++--- lwt/cohttp_lwt.mli | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/js/cohttp_lwt_xhr.ml b/js/cohttp_lwt_xhr.ml index 9e0ad34353..bde2f4e539 100644 --- a/js/cohttp_lwt_xhr.ml +++ b/js/cohttp_lwt_xhr.ml @@ -93,8 +93,7 @@ end) = struct let post_form ?ctx ?headers ~params uri = let headers = C.Header.add_opt headers "content-type" "application/x-www-form-urlencoded" in - let q = List.map (fun (k,v) -> k, [v]) (C.Header.to_list params) in - let body = Cohttp_lwt_body.of_string (Uri.encoded_of_query q) in + let body = Cohttp_lwt_body.of_string (Uri.encoded_of_query params) in post ?ctx ~chunked:false ~headers ~body uri (* No implementation (can it be done?). What should the failure exception be? *) diff --git a/lwt/cohttp_lwt.ml b/lwt/cohttp_lwt.ml index 582eb7cfff..ec8c1d8389 100644 --- a/lwt/cohttp_lwt.ml +++ b/lwt/cohttp_lwt.ml @@ -105,7 +105,7 @@ module type Client = sig val post_form : ?ctx:ctx -> ?headers:Cohttp.Header.t -> - params:Cohttp.Header.t -> + params:(string * string list) list -> Uri.t -> (Response.t * Cohttp_lwt_body.t) Lwt.t val callv : @@ -184,8 +184,7 @@ module Make_client let post_form ?ctx ?headers ~params uri = let headers = Header.add_opt headers "content-type" "application/x-www-form-urlencoded" in - let q = List.map (fun (k,v) -> k, [v]) (Header.to_list params) in - let body = Cohttp_lwt_body.of_string (Uri.encoded_of_query q) in + let body = Cohttp_lwt_body.of_string (Uri.encoded_of_query params) in post ?ctx ~chunked:false ~headers ~body uri let callv ?(ctx=default_ctx) uri reqs = diff --git a/lwt/cohttp_lwt.mli b/lwt/cohttp_lwt.mli index b758b2a8ea..688e87d60d 100644 --- a/lwt/cohttp_lwt.mli +++ b/lwt/cohttp_lwt.mli @@ -128,7 +128,7 @@ module type Client = sig val post_form : ?ctx:ctx -> ?headers:Cohttp.Header.t -> - params:Cohttp.Header.t -> + params:(string * string list) list -> Uri.t -> (Response.t * Cohttp_lwt_body.t) Lwt.t val callv :