Jackson Tale
Jackson Tale

Reputation: 25842

Where should I put `header` and `data` in Http_client.Convenience.http_post?

OCamlnet 3 has Http_client.Convenience.http_post.

Its API is like this:

val http_post : string -> (string * string) list -> string

Does a "POST" request with the given URL and returns the response body. The list contains the parameters send with the POST request.

My question is::

where should I supply the header and data body for the post request?

Upvotes: 2

Views: 99

Answers (1)

barti_ddu
barti_ddu

Reputation: 10299

AFAIR you can not provide custom header in Convenience method. However, you can always use the pipeline API:

let _ =
    let call = new Http_client.post
        "http://localhost:8080"
        [("param", "value")]
    in
    call#set_req_header "User-Agent" "Foozilla 1.0";
    call#set_req_header "Myheader" "foo";
    let pipeline = new Http_client.pipeline in
    pipeline#add call;
    pipeline#run ();

Upvotes: 2

Related Questions