Skip to content
Merged
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
8 changes: 5 additions & 3 deletions bin/cohttp_curl_async.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ open Cohttp_async
let show_headers h =
Cohttp.Header.iter (fun k v -> List.iter v ~f:(Printf.eprintf "%s: %s\n%!" k)) h

let make_net_req uri meth' () =
let make_net_req uri meth' body () =
let meth = Cohttp.Code.method_of_string meth' in
let uri = Uri.of_string uri in
let headers = Cohttp.Header.of_list [ "connection", "close" ] in
Client.call meth ~headers uri
Client.call meth ~headers ~body:Body.(of_string body) uri
>>= fun (res, body) ->
show_headers (Cohttp.Response.headers res);
body
Expand All @@ -38,7 +38,9 @@ let _ =
(empty
+> anon ("url" %: string)
+> flag "-X" (optional_with_default "GET" string)
~doc:" Set HTTP method"
~doc:" Set HTTP method"
+> flag "data-binary" (optional_with_default "" string)
~doc:" Data to send when using POST"
)
make_net_req
|> Command.run
Expand Down