OCamlnet 3 有 Http_client.Convenience.http_post
。
它的API是这样的:
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.
我的问题是:
我应该在哪里为post请求
提供 header 和数据正文?
最佳答案
AFAIR 您无法在便利方法中提供自定义 header 。但是,您始终可以使用管道 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 ();
关于ocaml - 我应该将 `header` 和 `data` 放在 Http_client.Convenience.http_post 中的哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17049143/