Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions async/cohttp_async.ml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ module Client = struct
let post ?interrupt ?headers ?(chunked=false) ?body uri =
call ?interrupt ?headers ~chunked ?body `POST uri

let post_form ?interrupt ?headers ~params uri =
let headers = Cohttp.Header.add_opt headers "content" "application/x-www-form-urlencoded" in
let body = Body.of_string (Uri.encoded_of_query params) in
post ?interrupt ~headers ~chunked:false ~body uri

let put ?interrupt ?headers ?(chunked=false) ?body uri =
call ?interrupt ?headers ~chunked ?body `PUT uri

Expand Down
8 changes: 8 additions & 0 deletions async/cohttp_async.mli
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ module Client : sig
Cohttp.Code.meth ->
Uri.t ->
(Response.t * Body.t) Deferred.t

(** Send an HTTP POST request in form format *)
val post_form:
?interrupt:unit Deferred.t ->
?headers:Cohttp.Header.t ->
params:(string * string list) list ->
Uri.t ->
(Response.t * Body.t) Deferred.t
end

module Server : sig
Expand Down