ocaml - 我应该将 `header` 和 `data` 放在 Http_client.Convenience.http_post 中的哪里?

标签 ocaml

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/

相关文章:

ocaml - 如何在Ocaml中实现俄罗斯娃娃模式?

algorithm - 将此算法转换为不使用递归的过程

jar - 无法链接到 Ocaml-java(或 Cafesterol)的标准库

vim - 如何使用 OCaml 进行语法错误检查?

c# - 在 C# 中表示参数化枚举的最佳方式?

oop - OCaml 中对象内的对象

http-post - Ocamlnet 3 的正确使用方法 - Http_client.Convenience.http_post

types - mli 文件和 ml 文件中的签名之间的 OCaml 共享结构

在 OCaml 函数的 C 实现中创建求和类型

ocaml - 如何拥有嵌套库?对沙丘等感到困惑