ocaml-opentelemetry/cohttp-lwt/Cohttp_lwt/Make_client/index.html
2025-03-27 13:35:42 +00:00

51 lines
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Make_client (cohttp-lwt.Cohttp_lwt.Make_client)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.0.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../../index.html">Index</a> &#x00BB; <a href="../../index.html">cohttp-lwt</a> &#x00BB; <a href="../index.html">Cohttp_lwt</a> &#x00BB; Make_client</nav><header class="odoc-preamble"><h1>Module <code><span>Cohttp_lwt.Make_client</span></code></h1></header><div class="odoc-tocs"><nav class="odoc-toc odoc-local-toc"><ul><li><a href="#parameters">Parameters</a></li><li><a href="#signature">Signature</a></li></ul></nav></div><div class="odoc-content"><h2 id="parameters"><a href="#parameters" class="anchor"></a>Parameters</h2><div class="odoc-spec"><div class="spec parameter anchored" id="argument-1-IO"><a href="#argument-1-IO" class="anchor"></a><code><span><span class="keyword">module</span> </span><span><a href="argument-1-IO/index.html">IO</a></span><span> : <a href="../S/module-type-IO/index.html">S.IO</a></span></code></div></div><div class="odoc-spec"><div class="spec parameter anchored" id="argument-2-Net"><a href="#argument-2-Net" class="anchor"></a><code><span><span class="keyword">module</span> </span><span><a href="argument-2-Net/index.html">Net</a></span><span> : <a href="../S/module-type-Net/index.html">S.Net</a> <span class="keyword">with</span> <span><span class="keyword">module</span> <a href="../S/module-type-Net/IO/index.html">IO</a> = <a href="argument-1-IO/index.html">IO</a></span></span></code></div></div><h2 id="signature"><a href="#signature" class="anchor"></a>Signature</h2><div class="odoc-spec"><div class="spec type anchored" id="type-ctx"><a href="#type-ctx" class="anchor"></a><code><span><span class="keyword">type</span> ctx</span><span> = <a href="argument-2-Net/index.html#type-ctx">Net.ctx</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-call"><a href="#val-call" class="anchor"></a><code><span><span class="keyword">val</span> call :
<span><span class="optlabel">?ctx</span>:<a href="#type-ctx">ctx</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?headers</span>:<a href="../../../cohttp/Cohttp/Header/index.html#type-t">Cohttp.Header.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?body</span>:<a href="../Body/index.html#type-t">Body.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?chunked</span>:bool <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../cohttp/Cohttp/Code/index.html#type-meth">Cohttp.Code.meth</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../uri/Uri/index.html#type-t">Uri.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <a href="../Body/index.html#type-t">Body.t</a>)</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>call ?ctx ?headers ?body ?chunked meth uri</code> will resolve the <code>uri</code> to a concrete network endpoint using context <code>ctx</code>. It will then issue an HTTP request with method <code>meth</code>, adding request headers from <code>headers</code> if present. If a <code>body</code> is specified then that will be included with the request, using chunked encoding if <code>chunked</code> is true. The default is to disable chunked encoding for HTTP request bodies for compatibility reasons.</p><p>In most cases you should use the more specific helper calls in the interface rather than invoke this function directly. See <a href="#val-head"><code>head</code></a>, <a href="#val-get"><code>get</code></a> and <a href="#val-post"><code>post</code></a> for some examples.</p><p>To avoid leaks, the body needs to be consumed, using the functions provided in the <a href="../Body/index.html"><code>Body</code></a> module and, if not necessary, should be explicitly drained calling <a href="../Body/index.html#val-drain_body"><code>Body.drain_body</code></a>. Leaks are logged as debug messages by the client, these can be enabled activating the debug logging. For example, this can be done as follows in <code>cohttp-lwt-unix</code></p><pre class="language-ocaml"><code> Cohttp_lwt_unix.Debug.activate_debug ();
Logs.set_level (Some Logs.Warning)</code></pre><p>Depending on <code>ctx</code>, the library is able to send a simple HTTP request or an encrypted one with a secured protocol (such as TLS). Depending on how conduit is configured, <code>ctx</code> might initiate a secured connection with TLS (using <code>ocaml-tls</code>) or SSL (using <code>ocaml-ssl</code>), on <code>*:443</code> or on the specified port by the user. If neitehr <code>ocaml-tls</code> or <code>ocaml-ssl</code> are installed on the system, <code>cohttp</code>/<code>conduit</code> tries the usual (<code>*:80</code>) or the specified port by the user in a non-secured way.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-head"><a href="#val-head" class="anchor"></a><code><span><span class="keyword">val</span> head :
<span><span class="optlabel">?ctx</span>:<a href="#type-ctx">ctx</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?headers</span>:<a href="../../../cohttp/Cohttp/Header/index.html#type-t">Cohttp.Header.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../uri/Uri/index.html#type-t">Uri.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get"><a href="#val-get" class="anchor"></a><code><span><span class="keyword">val</span> get :
<span><span class="optlabel">?ctx</span>:<a href="#type-ctx">ctx</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?headers</span>:<a href="../../../cohttp/Cohttp/Header/index.html#type-t">Cohttp.Header.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../uri/Uri/index.html#type-t">Uri.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <a href="../Body/index.html#type-t">Body.t</a>)</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-delete"><a href="#val-delete" class="anchor"></a><code><span><span class="keyword">val</span> delete :
<span><span class="optlabel">?ctx</span>:<a href="#type-ctx">ctx</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?body</span>:<a href="../Body/index.html#type-t">Body.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?chunked</span>:bool <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?headers</span>:<a href="../../../cohttp/Cohttp/Header/index.html#type-t">Cohttp.Header.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../uri/Uri/index.html#type-t">Uri.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <a href="../Body/index.html#type-t">Body.t</a>)</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-post"><a href="#val-post" class="anchor"></a><code><span><span class="keyword">val</span> post :
<span><span class="optlabel">?ctx</span>:<a href="#type-ctx">ctx</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?body</span>:<a href="../Body/index.html#type-t">Body.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?chunked</span>:bool <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?headers</span>:<a href="../../../cohttp/Cohttp/Header/index.html#type-t">Cohttp.Header.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../uri/Uri/index.html#type-t">Uri.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <a href="../Body/index.html#type-t">Body.t</a>)</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-put"><a href="#val-put" class="anchor"></a><code><span><span class="keyword">val</span> put :
<span><span class="optlabel">?ctx</span>:<a href="#type-ctx">ctx</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?body</span>:<a href="../Body/index.html#type-t">Body.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?chunked</span>:bool <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?headers</span>:<a href="../../../cohttp/Cohttp/Header/index.html#type-t">Cohttp.Header.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../uri/Uri/index.html#type-t">Uri.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <a href="../Body/index.html#type-t">Body.t</a>)</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-patch"><a href="#val-patch" class="anchor"></a><code><span><span class="keyword">val</span> patch :
<span><span class="optlabel">?ctx</span>:<a href="#type-ctx">ctx</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?body</span>:<a href="../Body/index.html#type-t">Body.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?chunked</span>:bool <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?headers</span>:<a href="../../../cohttp/Cohttp/Header/index.html#type-t">Cohttp.Header.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../uri/Uri/index.html#type-t">Uri.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <a href="../Body/index.html#type-t">Body.t</a>)</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-post_form"><a href="#val-post_form" class="anchor"></a><code><span><span class="keyword">val</span> post_form :
<span><span class="optlabel">?ctx</span>:<a href="#type-ctx">ctx</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?headers</span>:<a href="../../../cohttp/Cohttp/Header/index.html#type-t">Cohttp.Header.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">params</span>:<span><span>(string * <span>string list</span>)</span> list</span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../uri/Uri/index.html#type-t">Uri.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <a href="../Body/index.html#type-t">Body.t</a>)</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-callv"><a href="#val-callv" class="anchor"></a><code><span><span class="keyword">val</span> callv :
<span><span class="optlabel">?ctx</span>:<a href="#type-ctx">ctx</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../uri/Uri/index.html#type-t">Uri.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span><span>(<a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a> * <a href="../Body/index.html#type-t">Body.t</a>)</span> <a href="../../../lwt/Lwt_stream/index.html#type-t">Lwt_stream.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <a href="../Body/index.html#type-t">Body.t</a>)</span> <a href="../../../lwt/Lwt_stream/index.html#type-t">Lwt_stream.t</a></span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div></div></body></html>