summaryrefslogtreecommitdiffstats
path: root/docs/en/gun
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-10-03 13:39:41 +0200
committerLoïc Hoguin <[email protected]>2017-10-03 13:39:41 +0200
commitb5d4cb91f80c833795a2d87050c3674bb7aecdc5 (patch)
tree62bf0ad8326006fcd3407fcb7c34c844c0dc0874 /docs/en/gun
parent1f8d51dd2692fc3978080419987bbe4d49a41a90 (diff)
downloadninenines.eu-b5d4cb91f80c833795a2d87050c3674bb7aecdc5.tar.gz
ninenines.eu-b5d4cb91f80c833795a2d87050c3674bb7aecdc5.tar.bz2
ninenines.eu-b5d4cb91f80c833795a2d87050c3674bb7aecdc5.zip
Update Hugo, docs
Diffstat (limited to 'docs/en/gun')
-rw-r--r--docs/en/gun/1.0/guide/connect/index.html329
-rw-r--r--docs/en/gun/1.0/guide/http/index.html785
-rw-r--r--docs/en/gun/1.0/guide/index.html66
-rw-r--r--docs/en/gun/1.0/guide/introduction/index.html73
-rw-r--r--docs/en/gun/1.0/guide/protocols/index.html511
-rw-r--r--docs/en/gun/1.0/guide/start/index.html153
-rw-r--r--docs/en/gun/1.0/guide/websocket/index.html249
-rw-r--r--docs/en/gun/1.0/index.html2
-rw-r--r--docs/en/gun/1.0/manual/gun/index.html3452
-rw-r--r--docs/en/gun/1.0/manual/gun_app/index.html58
-rw-r--r--docs/en/gun/1.0/manual/index.html26
-rw-r--r--docs/en/gun/index.html2
12 files changed, 2864 insertions, 2842 deletions
diff --git a/docs/en/gun/1.0/guide/connect/index.html b/docs/en/gun/1.0/guide/connect/index.html
index 50035be4..62b1619d 100644
--- a/docs/en/gun/1.0/guide/connect/index.html
+++ b/docs/en/gun/1.0/guide/connect/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: Connection</title>
@@ -67,174 +67,177 @@
<h1 class="lined-header"><span>Connection</span></h1>
-<div class="paragraph"><p>This chapter describes how to open, monitor and close
-a connection using the Gun client.</p></div>
-<div class="sect1">
-<h2 id="_gun_connections">Gun connections</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Gun is designed with the HTTP/2 and Websocket protocols in mind.
-They are built for long-running connections that allow concurrent
-exchange of data, either in the form of request/responses for
-HTTP/2 or in the form of messages for Websocket.</p></div>
-<div class="paragraph"><p>A Gun connection is an Erlang process that manages a socket to
-a remote endpoint. This Gun connection is owned by a user
-process that is called the <em>owner</em> of the connection, and is
-managed by the supervision tree of the <code>gun</code> application.</p></div>
-<div class="paragraph"><p>The owner process communicates with the Gun connection
-by calling functions from the module <code>gun</code>. All functions
-perform their respective operations asynchronously. The Gun
-connection will send Erlang messages to the owner process
-whenever needed.</p></div>
-<div class="paragraph"><p>When the remote endpoint closes the connection, Gun attempts
-to reconnect automatically.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_opening_a_new_connection">Opening a new connection</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>The <code>gun:open/{2,3}</code> function must be used to open a connection.</p></div>
-<div class="listingblock">
-<div class="title">Opening a connection to example.org on port 443</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt>{<span style="color: #FF6600">ok</span>, <span style="color: #009900">ConnPid</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:open</span></span>(<span style="color: #FF0000">"example.org"</span>, <span style="color: #993399">443</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>If the port given is 443, Gun will attempt to connect using
-SSL. The protocol will be selected automatically using the
-ALPN extension for TLS. By default Gun supports HTTP/2
-and HTTP/1.1 when connecting using SSL.</p></div>
-<div class="paragraph"><p>For any other port, Gun will attempt to connect using TCP
-and will use the HTTP/1.1 protocol.</p></div>
-<div class="paragraph"><p>The transport and protocol used can be overriden using
-options. The manual documents all available options.</p></div>
-<div class="paragraph"><p>Options can be provided as a third argument, and take the
-form of a map.</p></div>
-<div class="listingblock">
-<div class="title">Opening an SSL connection to example.org on port 8443</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt>{<span style="color: #FF6600">ok</span>, <span style="color: #009900">ConnPid</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:open</span></span>(<span style="color: #FF0000">"example.org"</span>, <span style="color: #993399">8443</span>, #{<span style="color: #0000FF">transport</span><span style="color: #990000">=&gt;</span><span style="color: #FF6600">ssl</span>})<span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_waiting_for_the_connection_to_be_established">Waiting for the connection to be established</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>When Gun successfully connects to the server, it sends a
-<code>gun_up</code> message with the protocol that has been selected
-for the connection.</p></div>
-<div class="paragraph"><p>Gun provides the functions <code>gun:await_up/{1,2,3}</code> that wait
-for the <code>gun_up</code> message. They can optionally take a monitor
-reference and/or timeout value. If no monitor is provided,
-one will be created for the duration of the function call.</p></div>
-<div class="listingblock">
-<div class="title">Synchronous opening of a connection</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt>{<span style="color: #FF6600">ok</span>, <span style="color: #009900">ConnPid</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:open</span></span>(<span style="color: #FF0000">"example.org"</span>, <span style="color: #993399">443</span>),
-{<span style="color: #FF6600">ok</span>, <span style="color: #009900">Protocol</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:await_up</span></span>(<span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_handling_connection_loss">Handling connection loss</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>When the connection is lost, Gun will send a <code>gun_down</code>
-message indicating the current protocol, the reason the
-connection was lost and two list of stream references.</p></div>
-<div class="paragraph"><p>The first list indicates open streams that <em>may</em> have been
-processed by the server. The second list indicates open
-streams that the server did not process.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_monitoring_the_connection_process">Monitoring the connection process</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>@todo Gun should detect the owner process being killed</p></div>
-<div class="paragraph"><p>Because software errors are unavoidable, it is important to
-detect when the Gun process crashes. It is also important
-to detect when it exits normally. Erlang provides two ways
-to do that: links and monitors.</p></div>
-<div class="paragraph"><p>Gun leaves you the choice as to which one will be used.
-However, if you use the <code>gun:await/{2,3}</code> or <code>gun:await_body/{2,3}</code>
-functions, a monitor may be used for you to avoid getting
-stuck waiting for a message that will never come.</p></div>
-<div class="paragraph"><p>If you choose to monitor yourself you can do it on a permanent
-basis rather than on every message you will receive, saving
-resources. Indeed, the <code>gun:await/{3,4}</code> and <code>gun:await_body/{3,4}</code>
-functions both accept a monitor argument if you have one already.</p></div>
-<div class="listingblock">
-<div class="title">Monitoring the connection process</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt>{<span style="color: #FF6600">ok</span>, <span style="color: #009900">ConnPid</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:open</span></span>(<span style="color: #FF0000">"example.org"</span>, <span style="color: #993399">443</span>)<span style="color: #990000">.</span>
-<span style="color: #009900">MRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">monitor</span></span>(<span style="font-weight: bold"><span style="color: #000080">process</span></span>, <span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>This monitor reference can be kept and used until the connection
-process exits.</p></div>
-<div class="listingblock">
-<div class="title">Handling <code>DOWN</code> messages</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
- <span style="font-style: italic"><span style="color: #9A1900">%% Receive Gun messages here...</span></span>
- {<span style="color: #FF6600">'DOWN'</span>, <span style="color: #009900">Mref</span>, <span style="font-weight: bold"><span style="color: #000080">process</span></span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">Reason</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">error_logger:error_msg</span></span>(<span style="color: #FF0000">"Oops!"</span>),
- <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #009900">Reason</span>);
-<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>What to do when you receive a <code>DOWN</code> message is entirely up to you.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_closing_the_connection_abruptly">Closing the connection abruptly</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>The connection can be stopped abruptly at any time by calling
-the <code>gun:close/1</code> function.</p></div>
-<div class="listingblock">
-<div class="title">Immediate closing of the connection</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:close</span></span>(<span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>The process is stopped immediately without having a chance to
-perform the protocol&#8217;s closing handshake, if any.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_closing_the_connection_gracefully">Closing the connection gracefully</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>The connection can also be stopped gracefully by calling the
-<code>gun:shutdown/1</code> function.</p></div>
-<div class="listingblock">
-<div class="title">Graceful shutdown of the connection</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:shutdown</span></span>(<span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>Gun will refuse any new requests or messages after you call
-this function. It will however continue to send you messages
-for existing streams until they are all completed.</p></div>
-<div class="paragraph"><p>For example if you performed a GET request just before calling
-<code>gun:shutdown/1</code>, you will still receive the response before
-Gun closes the connection.</p></div>
-<div class="paragraph"><p>If you set a monitor beforehand, you will receive a message
-when the connection has been closed.</p></div>
-</div>
-</div>
+<div class="paragraph"><p>This chapter describes how to open, monitor and close
+a connection using the Gun client.</p></div>
+<div class="sect1">
+<h2 id="_gun_connections">Gun connections</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Gun is designed with the HTTP/2 and Websocket protocols in mind.
+They are built for long-running connections that allow concurrent
+exchange of data, either in the form of request/responses for
+HTTP/2 or in the form of messages for Websocket.</p></div>
+<div class="paragraph"><p>A Gun connection is an Erlang process that manages a socket to
+a remote endpoint. This Gun connection is owned by a user
+process that is called the <em>owner</em> of the connection, and is
+managed by the supervision tree of the <code>gun</code> application.</p></div>
+<div class="paragraph"><p>The owner process communicates with the Gun connection
+by calling functions from the module <code>gun</code>. All functions
+perform their respective operations asynchronously. The Gun
+connection will send Erlang messages to the owner process
+whenever needed.</p></div>
+<div class="paragraph"><p>When the remote endpoint closes the connection, Gun attempts
+to reconnect automatically.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_opening_a_new_connection">Opening a new connection</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The <code>gun:open/{2,3}</code> function must be used to open a connection.</p></div>
+<div class="listingblock">
+<div class="title">Opening a connection to example.org on port 443</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">ok</span>, <span style="color: #009900">ConnPid</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:open</span></span>(<span style="color: #FF0000">"example.org"</span>, <span style="color: #993399">443</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If the port given is 443, Gun will attempt to connect using
+SSL. The protocol will be selected automatically using the
+ALPN extension for TLS. By default Gun supports HTTP/2
+and HTTP/1.1 when connecting using SSL.</p></div>
+<div class="paragraph"><p>For any other port, Gun will attempt to connect using TCP
+and will use the HTTP/1.1 protocol.</p></div>
+<div class="paragraph"><p>The transport and protocol used can be overriden using
+options. The manual documents all available options.</p></div>
+<div class="paragraph"><p>Options can be provided as a third argument, and take the
+form of a map.</p></div>
+<div class="listingblock">
+<div class="title">Opening an SSL connection to example.org on port 8443</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">ok</span>, <span style="color: #009900">ConnPid</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:open</span></span>(<span style="color: #FF0000">"example.org"</span>, <span style="color: #993399">8443</span>, #{<span style="color: #0000FF">transport</span><span style="color: #990000">=&gt;</span><span style="color: #FF6600">ssl</span>})<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_waiting_for_the_connection_to_be_established">Waiting for the connection to be established</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>When Gun successfully connects to the server, it sends a
+<code>gun_up</code> message with the protocol that has been selected
+for the connection.</p></div>
+<div class="paragraph"><p>Gun provides the functions <code>gun:await_up/{1,2,3}</code> that wait
+for the <code>gun_up</code> message. They can optionally take a monitor
+reference and/or timeout value. If no monitor is provided,
+one will be created for the duration of the function call.</p></div>
+<div class="listingblock">
+<div class="title">Synchronous opening of a connection</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">ok</span>, <span style="color: #009900">ConnPid</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:open</span></span>(<span style="color: #FF0000">"example.org"</span>, <span style="color: #993399">443</span>),
+{<span style="color: #FF6600">ok</span>, <span style="color: #009900">Protocol</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:await_up</span></span>(<span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_handling_connection_loss">Handling connection loss</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>When the connection is lost, Gun will send a <code>gun_down</code>
+message indicating the current protocol, the reason the
+connection was lost and two list of stream references.</p></div>
+<div class="paragraph"><p>The first list indicates open streams that <em>may</em> have been
+processed by the server. The second list indicates open
+streams that the server did not process.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_monitoring_the_connection_process">Monitoring the connection process</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>@todo Gun should detect the owner process being killed</p></div>
+<div class="paragraph"><p>Because software errors are unavoidable, it is important to
+detect when the Gun process crashes. It is also important
+to detect when it exits normally. Erlang provides two ways
+to do that: links and monitors.</p></div>
+<div class="paragraph"><p>Gun leaves you the choice as to which one will be used.
+However, if you use the <code>gun:await/{2,3}</code> or <code>gun:await_body/{2,3}</code>
+functions, a monitor may be used for you to avoid getting
+stuck waiting for a message that will never come.</p></div>
+<div class="paragraph"><p>If you choose to monitor yourself you can do it on a permanent
+basis rather than on every message you will receive, saving
+resources. Indeed, the <code>gun:await/{3,4}</code> and <code>gun:await_body/{3,4}</code>
+functions both accept a monitor argument if you have one already.</p></div>
+<div class="listingblock">
+<div class="title">Monitoring the connection process</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">ok</span>, <span style="color: #009900">ConnPid</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:open</span></span>(<span style="color: #FF0000">"example.org"</span>, <span style="color: #993399">443</span>)<span style="color: #990000">.</span>
+<span style="color: #009900">MRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">monitor</span></span>(<span style="font-weight: bold"><span style="color: #000080">process</span></span>, <span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>This monitor reference can be kept and used until the connection
+process exits.</p></div>
+<div class="listingblock">
+<div class="title">Handling <code>DOWN</code> messages</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
+ <span style="font-style: italic"><span style="color: #9A1900">%% Receive Gun messages here...</span></span>
+ {<span style="color: #FF6600">'DOWN'</span>, <span style="color: #009900">Mref</span>, <span style="font-weight: bold"><span style="color: #000080">process</span></span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">Reason</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">error_logger:error_msg</span></span>(<span style="color: #FF0000">"Oops!"</span>),
+ <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #009900">Reason</span>);
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>What to do when you receive a <code>DOWN</code> message is entirely up to you.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_closing_the_connection_abruptly">Closing the connection abruptly</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The connection can be stopped abruptly at any time by calling
+the <code>gun:close/1</code> function.</p></div>
+<div class="listingblock">
+<div class="title">Immediate closing of the connection</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:close</span></span>(<span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The process is stopped immediately without having a chance to
+perform the protocol&#8217;s closing handshake, if any.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_closing_the_connection_gracefully">Closing the connection gracefully</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The connection can also be stopped gracefully by calling the
+<code>gun:shutdown/1</code> function.</p></div>
+<div class="listingblock">
+<div class="title">Graceful shutdown of the connection</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:shutdown</span></span>(<span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Gun will refuse any new requests or messages after you call
+this function. It will however continue to send you messages
+for existing streams until they are all completed.</p></div>
+<div class="paragraph"><p>For example if you performed a GET request just before calling
+<code>gun:shutdown/1</code>, you will still receive the response before
+Gun closes the connection.</p></div>
+<div class="paragraph"><p>If you set a monitor beforehand, you will receive a message
+when the connection has been closed.</p></div>
+</div>
+</div>
+
+
+
<nav style="margin:1em 0">
diff --git a/docs/en/gun/1.0/guide/http/index.html b/docs/en/gun/1.0/guide/http/index.html
index 668d3ff6..bbdb81ed 100644
--- a/docs/en/gun/1.0/guide/http/index.html
+++ b/docs/en/gun/1.0/guide/http/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: HTTP</title>
@@ -67,402 +67,405 @@
<h1 class="lined-header"><span>HTTP</span></h1>
-<div class="paragraph"><p>This chapter describes how to use the Gun client for
-communicating with an HTTP/1.1 or HTTP/2 server.</p></div>
-<div class="sect1">
-<h2 id="_streams">Streams</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Every time a request is initiated, Gun creates a <em>stream</em>.
-A <em>stream reference</em> uniquely identifies a set of request and
-response(s) and must be used to perform additional operations
-with a stream or to identify its messages.</p></div>
-<div class="paragraph"><p>Stream references use the Erlang <em>reference</em> data type and
-are therefore unique.</p></div>
-<div class="paragraph"><p>Streams can be canceled at any time. This will stop any further
-messages from being sent to the owner process. Depending on
-its capabilities, the server will also be instructed to cancel
-the request.</p></div>
-<div class="paragraph"><p>Canceling a stream may result in Gun dropping the connection
-temporarily, to avoid uploading or downloading data that will
-not be used.</p></div>
-<div class="listingblock">
-<div class="title">Cancelling a stream</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:cancel</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_sending_requests">Sending requests</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Gun provides many convenient functions for performing common
-operations, like GET, POST or DELETE. It also provides a
-general purpose function in case you need other methods.</p></div>
-<div class="paragraph"><p>The availability of these methods on the server can vary
-depending on the software used but also on a per-resource
-basis.</p></div>
-<div class="paragraph"><p>Gun will automatically set a few headers depending on the
-method used. For all methods however it will set the host
-header if it has not been provided in the request arguments.</p></div>
-<div class="paragraph"><p>This section focuses on the act of sending a request. The
-handling of responses will be explained further on.</p></div>
-<div class="sect3">
-<h4 id="_get_and_head">GET and HEAD</h4>
-<div class="paragraph"><p>Use <code>gun:get/{2,3,4}</code> to request a resource.</p></div>
-<div class="listingblock">
-<div class="title">GET "/organizations/ninenines"</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="listingblock">
-<div class="title">GET "/organizations/ninenines" with custom headers</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"accept"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"application/json"</span>},
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"user-agent"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"revolver/1.0"</span>}
-])<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>Note that the list of headers has the field name as a binary.
-The field value is iodata, which is either a binary or an
-iolist.</p></div>
-<div class="paragraph"><p>Use <code>gun:head/{2,3,4}</code> if you don&#8217;t need the response body.</p></div>
-<div class="listingblock">
-<div class="title">HEAD "/organizations/ninenines"</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:head</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="listingblock">
-<div class="title">HEAD "/organizations/ninenines" with custom headers</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:head</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"accept"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"application/json"</span>},
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"user-agent"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"revolver/1.0"</span>}
-])<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>It is not possible to send a request body with a GET or HEAD
-request.</p></div>
-</div>
-<div class="sect3">
-<h4 id="_post_put_and_patch">POST, PUT and PATCH</h4>
-<div class="paragraph"><p>HTTP defines three methods to create or update a resource.</p></div>
-<div class="paragraph"><p>POST is generally used when the resource identifier (URI) isn&#8217;t known
-in advance when creating the resource. POST can also be used to
-replace an existing resource, although PUT is more appropriate
-in that situation.</p></div>
-<div class="paragraph"><p>PUT creates or replaces a resource identified by the URI.</p></div>
-<div class="paragraph"><p>PATCH provides instructions on how to modify the resource.</p></div>
-<div class="paragraph"><p>Both POST and PUT send the entire resource representation in their
-request body. The PATCH method can be used when this is not
-desirable. The request body of a PATCH method may be a partial
-representation or a list of instructions on how to update the
-resource.</p></div>
-<div class="paragraph"><p>The <code>gun:post/{4,5}</code>, <code>gun:put/{4,5}</code> and <code>gun:patch/{4,5}</code> functions
-take a body as their fourth argument. These functions do
-not require any body-specific header to be set, although
-it is always recommended to set the content-type header.
-Gun will set the other headers automatically.</p></div>
-<div class="paragraph"><p>In this and the following examples in this section, <code>gun:post</code>
-can be replaced by <code>gun:put</code> or <code>gun:patch</code> for performing
-a PUT or PATCH request, respectively.</p></div>
-<div class="listingblock">
-<div class="title">POST "/organizations/ninenines"</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">Body</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"{\"msg\": \"Hello world!\"}"</span>,
-<span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:post</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"application/json"</span>}
-], <span style="color: #009900">Body</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>The <code>gun:post/3</code>, <code>gun:put/3</code> and <code>gun:patch/3</code> functions
-do not take a body in their arguments. If a body is to be
-provided later on, using the <code>gun:data/4</code> function, then
-the request headers must indicate this. This can be done
-by setting the content-length or content-type request
-headers. If these headers are not set then Gun will assume
-the request has no body.</p></div>
-<div class="paragraph"><p>It is recommended to send the content-length header if you
-know it in advance, although this is not required. If it
-is not set, HTTP/1.1 will use the chunked transfer-encoding,
-and HTTP/2 will continue normally as it is chunked by design.</p></div>
-<div class="listingblock">
-<div class="title">POST "/organizations/ninenines" with delayed body</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">Body</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"{\"msg\": \"Hello world!\"}"</span>,
-<span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:post</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"content-length"</span><span style="color: #990000">&gt;&gt;</span>, <span style="font-weight: bold"><span style="color: #000000">integer_to_binary</span></span>(<span style="font-weight: bold"><span style="color: #000080">length</span></span>(<span style="color: #009900">Body</span>))},
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"application/json"</span>}
-]),
-<span style="font-weight: bold"><span style="color: #000000">gun:data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">fin</span>, <span style="color: #009900">Body</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>The atom <code>fin</code> indicates this is the last chunk of data to
-be sent. You can call the <code>gun:data/4</code> function as many
-times as needed until you have sent the entire body. The
-last call must use <code>fin</code> and all the previous calls must
-use <code>nofin</code>. The last chunk may be empty.</p></div>
-<div class="paragraph"><p>@todo what to do about empty chunk, ignore?</p></div>
-<div class="listingblock">
-<div class="title">Streaming the request body</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">sendfile</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">Filepath</span>) <span style="color: #990000">-&gt;</span>
- {<span style="color: #FF6600">ok</span>, <span style="color: #009900">IoDevice</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">file:open</span></span>(<span style="color: #009900">Filepath</span>, [<span style="color: #FF6600">read</span>, <span style="font-weight: bold"><span style="color: #000080">binary</span></span>, <span style="color: #FF6600">raw</span>]),
- <span style="font-weight: bold"><span style="color: #000000">do_sendfile</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">IoDevice</span>)<span style="color: #990000">.</span>
-
-<span style="font-weight: bold"><span style="color: #000000">do_sendfile</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">IoDevice</span>) <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">file:read</span></span>(<span style="color: #009900">IoDevice</span>, <span style="color: #993399">8000</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
- <span style="color: #FF6600">eof</span> <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">gun:data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">fin</span>, <span style="color: #990000">&lt;&lt;&gt;&gt;</span>),
- <span style="font-weight: bold"><span style="color: #000000">file:close</span></span>(<span style="color: #009900">IoDevice</span>);
- {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Bin</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">gun:data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">nofin</span>, <span style="color: #009900">Bin</span>),
- <span style="font-weight: bold"><span style="color: #000000">do_sendfile</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">IoDevice</span>)
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-<div class="sect3">
-<h4 id="_delete">DELETE</h4>
-<div class="paragraph"><p>Use <code>gun:delete/{2,3,4}</code> to delete a resource.</p></div>
-<div class="listingblock">
-<div class="title">DELETE "/organizations/ninenines"</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:delete</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="listingblock">
-<div class="title">DELETE "/organizations/ninenines" with custom headers</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:delete</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"user-agent"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"revolver/1.0"</span>}
-])<span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-<div class="sect3">
-<h4 id="_options">OPTIONS</h4>
-<div class="paragraph"><p>Use <code>gun:options/{2,3}</code> to request information about a resource.</p></div>
-<div class="listingblock">
-<div class="title">OPTIONS "/organizations/ninenines"</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:options</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="listingblock">
-<div class="title">OPTIONS "/organizations/ninenines" with custom headers</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:options</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"user-agent"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"revolver/1.0"</span>}
-])<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>You can also use this function to request information about
-the server itself.</p></div>
-<div class="listingblock">
-<div class="title">OPTIONS "*"</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:options</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"*"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-<div class="sect3">
-<h4 id="_requests_with_an_arbitrary_method">Requests with an arbitrary method</h4>
-<div class="paragraph"><p>The <code>gun:request/{4,5,6}</code> function can be used to send requests
-with a configurable method name. It is mostly useful when you
-need a method that Gun does not understand natively.</p></div>
-<div class="listingblock">
-<div class="title">Example of a TRACE request</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:request</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"TRACE"</span>, <span style="color: #FF0000">"/"</span>, [
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"max-forwards"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"30"</span>}
-])<span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_processing_responses">Processing responses</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>All data received from the server is sent to the owner
-process as a message. First a <code>gun_response</code> message is sent,
-followed by zero or more <code>gun_data</code> messages. If something goes wrong,
-a <code>gun_error</code> message is sent instead.</p></div>
-<div class="paragraph"><p>The response message will inform you whether there will be
-data messages following. If it contains <code>fin</code> there will be
-no data messages. If it contains <code>nofin</code> then one or more data
-messages will follow.</p></div>
-<div class="paragraph"><p>When using HTTP/2 this value is sent with the frame and simply
-passed on in the message. When using HTTP/1.1 however Gun must
-guess whether data will follow by looking at the response headers.</p></div>
-<div class="paragraph"><p>You can receive messages directly, or you can use the <em>await</em>
-functions to let Gun receive them for you.</p></div>
-<div class="listingblock">
-<div class="title">Receiving a response using receive</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">print_body</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">MRef</span>) <span style="color: #990000">-&gt;</span>
- <span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/"</span>),
- <span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
- {<span style="color: #FF6600">gun_response</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">fin</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
- <span style="color: #FF6600">no_data</span>;
- {<span style="color: #FF6600">gun_response</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">nofin</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">receive_data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">MRef</span>, <span style="color: #009900">StreamRef</span>);
- {<span style="color: #FF6600">'DOWN'</span>, <span style="color: #009900">MRef</span>, <span style="font-weight: bold"><span style="color: #000080">process</span></span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">Reason</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">error_logger:error_msg</span></span>(<span style="color: #FF0000">"Oops!"</span>),
- <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #009900">Reason</span>)
- <span style="font-weight: bold"><span style="color: #0000FF">after</span></span> <span style="color: #993399">1000</span> <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #FF6600">timeout</span>)
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span>
-
-<span style="font-weight: bold"><span style="color: #000000">receive_data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">MRef</span>, <span style="color: #009900">StreamRef</span>) <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
- {<span style="color: #FF6600">gun_data</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">nofin</span>, <span style="color: #009900">Data</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">io:format</span></span>(<span style="color: #FF0000">"~s~n"</span>, [<span style="color: #009900">Data</span>]),
- <span style="font-weight: bold"><span style="color: #000000">receive_data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">MRef</span>, <span style="color: #009900">StreamRef</span>);
- {<span style="color: #FF6600">gun_data</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">fin</span>, <span style="color: #009900">Data</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">io:format</span></span>(<span style="color: #FF0000">"~s~n"</span>, [<span style="color: #009900">Data</span>]);
- {<span style="color: #FF6600">'DOWN'</span>, <span style="color: #009900">MRef</span>, <span style="font-weight: bold"><span style="color: #000080">process</span></span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">Reason</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">error_logger:error_msg</span></span>(<span style="color: #FF0000">"Oops!"</span>),
- <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #009900">Reason</span>)
- <span style="font-weight: bold"><span style="color: #0000FF">after</span></span> <span style="color: #993399">1000</span> <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #FF6600">timeout</span>)
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>While it may seem verbose, using messages like this has the
-advantage of never locking your process, allowing you to
-easily debug your code. It also allows you to start more than
-one connection and concurrently perform queries on all of them
-at the same time.</p></div>
-<div class="paragraph"><p>You can also use Gun in a synchronous manner by using the <em>await</em>
-functions.</p></div>
-<div class="paragraph"><p>The <code>gun:await/{2,3,4}</code> function will wait until it receives
-a response to, a pushed resource related to, or data from
-the given stream.</p></div>
-<div class="paragraph"><p>When calling <code>gun:await/{2,3}</code> and not passing a monitor
-reference, one is automatically created for you for the
-duration of the call.</p></div>
-<div class="paragraph"><p>The <code>gun:await_body/{2,3,4}</code> works similarly, but returns the
-body received. Both functions can be combined to receive the
-response and its body sequentially.</p></div>
-<div class="listingblock">
-<div class="title">Receiving a response using await</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/"</span>),
-<span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">gun:await</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
- {<span style="color: #FF6600">response</span>, <span style="color: #FF6600">fin</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
- <span style="color: #FF6600">no_data</span>;
- {<span style="color: #FF6600">response</span>, <span style="color: #FF6600">nofin</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
- {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Body</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:await_body</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>),
- <span style="font-weight: bold"><span style="color: #000000">io:format</span></span>(<span style="color: #FF0000">"~s~n"</span>, [<span style="color: #009900">Body</span>])
-<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_handling_streams_pushed_by_the_server">Handling streams pushed by the server</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>The HTTP/2 protocol allows the server to push more than one
-resource for every request. It will start sending those
-extra resources before it starts sending the response itself,
-so Gun will send you <code>gun_push</code> messages before <code>gun_response</code>
-when that happens.</p></div>
-<div class="paragraph"><p>You can safely choose to ignore <code>gun_push</code> messages, or
-you can handle them. If you do, you can either receive the
-messages directly or use <em>await</em> functions.</p></div>
-<div class="paragraph"><p>The <code>gun_push</code> message contains both the new stream reference
-and the stream reference of the original request.</p></div>
-<div class="listingblock">
-<div class="title">Receiving a pushed response using receive</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
- {<span style="color: #FF6600">gun_push</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">OriginalStreamRef</span>, <span style="color: #009900">PushedStreamRef</span>,
- <span style="color: #009900">Method</span>, <span style="color: #009900">Host</span>, <span style="color: #009900">Path</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">enjoy</span></span>()
-<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>If you use the <code>gun:await/{2,3,4}</code> function, however, Gun
-will use the original reference to identify the message but
-will return a tuple that doesn&#8217;t contain it.</p></div>
-<div class="listingblock">
-<div class="title">Receiving a pushed response using await</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt>{<span style="color: #FF6600">push</span>, <span style="color: #009900">PushedStreamRef</span>, <span style="color: #009900">Method</span>, <span style="color: #009900">Host</span>, <span style="color: #009900">Path</span>, <span style="color: #009900">Headers</span>}
- <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:await</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">OriginalStreamRef</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>The <code>PushedStreamRef</code> variable can then be used with <code>gun:await_body/{2,3,4}</code>
-if needed.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_flushing_unwanted_messages">Flushing unwanted messages</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Gun provides the function <code>gun:flush/1</code> to quickly get rid
-of unwanted messages sitting in the process mailbox. You
-can use it to get rid of all messages related to a connection,
-or just the messages related to a stream.</p></div>
-<div class="listingblock">
-<div class="title">Flush all messages from a Gun connection</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:flush</span></span>(<span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="listingblock">
-<div class="title">Flush all messages from a specific stream</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:flush</span></span>(<span style="color: #009900">StreamRef</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_redirecting_responses_to_a_different_process">Redirecting responses to a different process</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Gun allows you to specify which process will handle responses
-to a request via the <code>reply_to</code> request option.</p></div>
-<div class="listingblock">
-<div class="title">GET "/organizations/ninenines" to a different process</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [],
- #{<span style="color: #0000FF">reply_to</span> <span style="color: #990000">=&gt;</span> <span style="color: #009900">Pid</span>})<span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-</div>
+<div class="paragraph"><p>This chapter describes how to use the Gun client for
+communicating with an HTTP/1.1 or HTTP/2 server.</p></div>
+<div class="sect1">
+<h2 id="_streams">Streams</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Every time a request is initiated, Gun creates a <em>stream</em>.
+A <em>stream reference</em> uniquely identifies a set of request and
+response(s) and must be used to perform additional operations
+with a stream or to identify its messages.</p></div>
+<div class="paragraph"><p>Stream references use the Erlang <em>reference</em> data type and
+are therefore unique.</p></div>
+<div class="paragraph"><p>Streams can be canceled at any time. This will stop any further
+messages from being sent to the owner process. Depending on
+its capabilities, the server will also be instructed to cancel
+the request.</p></div>
+<div class="paragraph"><p>Canceling a stream may result in Gun dropping the connection
+temporarily, to avoid uploading or downloading data that will
+not be used.</p></div>
+<div class="listingblock">
+<div class="title">Cancelling a stream</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:cancel</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_sending_requests">Sending requests</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Gun provides many convenient functions for performing common
+operations, like GET, POST or DELETE. It also provides a
+general purpose function in case you need other methods.</p></div>
+<div class="paragraph"><p>The availability of these methods on the server can vary
+depending on the software used but also on a per-resource
+basis.</p></div>
+<div class="paragraph"><p>Gun will automatically set a few headers depending on the
+method used. For all methods however it will set the host
+header if it has not been provided in the request arguments.</p></div>
+<div class="paragraph"><p>This section focuses on the act of sending a request. The
+handling of responses will be explained further on.</p></div>
+<div class="sect3">
+<h4 id="_get_and_head">GET and HEAD</h4>
+<div class="paragraph"><p>Use <code>gun:get/{2,3,4}</code> to request a resource.</p></div>
+<div class="listingblock">
+<div class="title">GET "/organizations/ninenines"</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="listingblock">
+<div class="title">GET "/organizations/ninenines" with custom headers</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"accept"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"application/json"</span>},
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"user-agent"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"revolver/1.0"</span>}
+])<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that the list of headers has the field name as a binary.
+The field value is iodata, which is either a binary or an
+iolist.</p></div>
+<div class="paragraph"><p>Use <code>gun:head/{2,3,4}</code> if you don&#8217;t need the response body.</p></div>
+<div class="listingblock">
+<div class="title">HEAD "/organizations/ninenines"</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:head</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="listingblock">
+<div class="title">HEAD "/organizations/ninenines" with custom headers</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:head</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"accept"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"application/json"</span>},
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"user-agent"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"revolver/1.0"</span>}
+])<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>It is not possible to send a request body with a GET or HEAD
+request.</p></div>
+</div>
+<div class="sect3">
+<h4 id="_post_put_and_patch">POST, PUT and PATCH</h4>
+<div class="paragraph"><p>HTTP defines three methods to create or update a resource.</p></div>
+<div class="paragraph"><p>POST is generally used when the resource identifier (URI) isn&#8217;t known
+in advance when creating the resource. POST can also be used to
+replace an existing resource, although PUT is more appropriate
+in that situation.</p></div>
+<div class="paragraph"><p>PUT creates or replaces a resource identified by the URI.</p></div>
+<div class="paragraph"><p>PATCH provides instructions on how to modify the resource.</p></div>
+<div class="paragraph"><p>Both POST and PUT send the entire resource representation in their
+request body. The PATCH method can be used when this is not
+desirable. The request body of a PATCH method may be a partial
+representation or a list of instructions on how to update the
+resource.</p></div>
+<div class="paragraph"><p>The <code>gun:post/{4,5}</code>, <code>gun:put/{4,5}</code> and <code>gun:patch/{4,5}</code> functions
+take a body as their fourth argument. These functions do
+not require any body-specific header to be set, although
+it is always recommended to set the content-type header.
+Gun will set the other headers automatically.</p></div>
+<div class="paragraph"><p>In this and the following examples in this section, <code>gun:post</code>
+can be replaced by <code>gun:put</code> or <code>gun:patch</code> for performing
+a PUT or PATCH request, respectively.</p></div>
+<div class="listingblock">
+<div class="title">POST "/organizations/ninenines"</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">Body</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"{\"msg\": \"Hello world!\"}"</span>,
+<span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:post</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"application/json"</span>}
+], <span style="color: #009900">Body</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The <code>gun:post/3</code>, <code>gun:put/3</code> and <code>gun:patch/3</code> functions
+do not take a body in their arguments. If a body is to be
+provided later on, using the <code>gun:data/4</code> function, then
+the request headers must indicate this. This can be done
+by setting the content-length or content-type request
+headers. If these headers are not set then Gun will assume
+the request has no body.</p></div>
+<div class="paragraph"><p>It is recommended to send the content-length header if you
+know it in advance, although this is not required. If it
+is not set, HTTP/1.1 will use the chunked transfer-encoding,
+and HTTP/2 will continue normally as it is chunked by design.</p></div>
+<div class="listingblock">
+<div class="title">POST "/organizations/ninenines" with delayed body</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">Body</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"{\"msg\": \"Hello world!\"}"</span>,
+<span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:post</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"content-length"</span><span style="color: #990000">&gt;&gt;</span>, <span style="font-weight: bold"><span style="color: #000000">integer_to_binary</span></span>(<span style="font-weight: bold"><span style="color: #000080">length</span></span>(<span style="color: #009900">Body</span>))},
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"application/json"</span>}
+]),
+<span style="font-weight: bold"><span style="color: #000000">gun:data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">fin</span>, <span style="color: #009900">Body</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The atom <code>fin</code> indicates this is the last chunk of data to
+be sent. You can call the <code>gun:data/4</code> function as many
+times as needed until you have sent the entire body. The
+last call must use <code>fin</code> and all the previous calls must
+use <code>nofin</code>. The last chunk may be empty.</p></div>
+<div class="paragraph"><p>@todo what to do about empty chunk, ignore?</p></div>
+<div class="listingblock">
+<div class="title">Streaming the request body</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">sendfile</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">Filepath</span>) <span style="color: #990000">-&gt;</span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">IoDevice</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">file:open</span></span>(<span style="color: #009900">Filepath</span>, [<span style="color: #FF6600">read</span>, <span style="font-weight: bold"><span style="color: #000080">binary</span></span>, <span style="color: #FF6600">raw</span>]),
+ <span style="font-weight: bold"><span style="color: #000000">do_sendfile</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">IoDevice</span>)<span style="color: #990000">.</span>
+
+<span style="font-weight: bold"><span style="color: #000000">do_sendfile</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">IoDevice</span>) <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">file:read</span></span>(<span style="color: #009900">IoDevice</span>, <span style="color: #993399">8000</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ <span style="color: #FF6600">eof</span> <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">gun:data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">fin</span>, <span style="color: #990000">&lt;&lt;&gt;&gt;</span>),
+ <span style="font-weight: bold"><span style="color: #000000">file:close</span></span>(<span style="color: #009900">IoDevice</span>);
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Bin</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">gun:data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">nofin</span>, <span style="color: #009900">Bin</span>),
+ <span style="font-weight: bold"><span style="color: #000000">do_sendfile</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">IoDevice</span>)
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+<div class="sect3">
+<h4 id="_delete">DELETE</h4>
+<div class="paragraph"><p>Use <code>gun:delete/{2,3,4}</code> to delete a resource.</p></div>
+<div class="listingblock">
+<div class="title">DELETE "/organizations/ninenines"</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:delete</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="listingblock">
+<div class="title">DELETE "/organizations/ninenines" with custom headers</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:delete</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"user-agent"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"revolver/1.0"</span>}
+])<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+<div class="sect3">
+<h4 id="_options">OPTIONS</h4>
+<div class="paragraph"><p>Use <code>gun:options/{2,3}</code> to request information about a resource.</p></div>
+<div class="listingblock">
+<div class="title">OPTIONS "/organizations/ninenines"</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:options</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="listingblock">
+<div class="title">OPTIONS "/organizations/ninenines" with custom headers</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:options</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"user-agent"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"revolver/1.0"</span>}
+])<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can also use this function to request information about
+the server itself.</p></div>
+<div class="listingblock">
+<div class="title">OPTIONS "*"</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:options</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"*"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+<div class="sect3">
+<h4 id="_requests_with_an_arbitrary_method">Requests with an arbitrary method</h4>
+<div class="paragraph"><p>The <code>gun:request/{4,5,6}</code> function can be used to send requests
+with a configurable method name. It is mostly useful when you
+need a method that Gun does not understand natively.</p></div>
+<div class="listingblock">
+<div class="title">Example of a TRACE request</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:request</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"TRACE"</span>, <span style="color: #FF0000">"/"</span>, [
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"max-forwards"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"30"</span>}
+])<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_processing_responses">Processing responses</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>All data received from the server is sent to the owner
+process as a message. First a <code>gun_response</code> message is sent,
+followed by zero or more <code>gun_data</code> messages. If something goes wrong,
+a <code>gun_error</code> message is sent instead.</p></div>
+<div class="paragraph"><p>The response message will inform you whether there will be
+data messages following. If it contains <code>fin</code> there will be
+no data messages. If it contains <code>nofin</code> then one or more data
+messages will follow.</p></div>
+<div class="paragraph"><p>When using HTTP/2 this value is sent with the frame and simply
+passed on in the message. When using HTTP/1.1 however Gun must
+guess whether data will follow by looking at the response headers.</p></div>
+<div class="paragraph"><p>You can receive messages directly, or you can use the <em>await</em>
+functions to let Gun receive them for you.</p></div>
+<div class="listingblock">
+<div class="title">Receiving a response using receive</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">print_body</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">MRef</span>) <span style="color: #990000">-&gt;</span>
+ <span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/"</span>),
+ <span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
+ {<span style="color: #FF6600">gun_response</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">fin</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
+ <span style="color: #FF6600">no_data</span>;
+ {<span style="color: #FF6600">gun_response</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">nofin</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">receive_data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">MRef</span>, <span style="color: #009900">StreamRef</span>);
+ {<span style="color: #FF6600">'DOWN'</span>, <span style="color: #009900">MRef</span>, <span style="font-weight: bold"><span style="color: #000080">process</span></span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">Reason</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">error_logger:error_msg</span></span>(<span style="color: #FF0000">"Oops!"</span>),
+ <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #009900">Reason</span>)
+ <span style="font-weight: bold"><span style="color: #0000FF">after</span></span> <span style="color: #993399">1000</span> <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #FF6600">timeout</span>)
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span>
+
+<span style="font-weight: bold"><span style="color: #000000">receive_data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">MRef</span>, <span style="color: #009900">StreamRef</span>) <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
+ {<span style="color: #FF6600">gun_data</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">nofin</span>, <span style="color: #009900">Data</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">io:format</span></span>(<span style="color: #FF0000">"~s~n"</span>, [<span style="color: #009900">Data</span>]),
+ <span style="font-weight: bold"><span style="color: #000000">receive_data</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">MRef</span>, <span style="color: #009900">StreamRef</span>);
+ {<span style="color: #FF6600">gun_data</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #FF6600">fin</span>, <span style="color: #009900">Data</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">io:format</span></span>(<span style="color: #FF0000">"~s~n"</span>, [<span style="color: #009900">Data</span>]);
+ {<span style="color: #FF6600">'DOWN'</span>, <span style="color: #009900">MRef</span>, <span style="font-weight: bold"><span style="color: #000080">process</span></span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">Reason</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">error_logger:error_msg</span></span>(<span style="color: #FF0000">"Oops!"</span>),
+ <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #009900">Reason</span>)
+ <span style="font-weight: bold"><span style="color: #0000FF">after</span></span> <span style="color: #993399">1000</span> <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #FF6600">timeout</span>)
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>While it may seem verbose, using messages like this has the
+advantage of never locking your process, allowing you to
+easily debug your code. It also allows you to start more than
+one connection and concurrently perform queries on all of them
+at the same time.</p></div>
+<div class="paragraph"><p>You can also use Gun in a synchronous manner by using the <em>await</em>
+functions.</p></div>
+<div class="paragraph"><p>The <code>gun:await/{2,3,4}</code> function will wait until it receives
+a response to, a pushed resource related to, or data from
+the given stream.</p></div>
+<div class="paragraph"><p>When calling <code>gun:await/{2,3}</code> and not passing a monitor
+reference, one is automatically created for you for the
+duration of the call.</p></div>
+<div class="paragraph"><p>The <code>gun:await_body/{2,3,4}</code> works similarly, but returns the
+body received. Both functions can be combined to receive the
+response and its body sequentially.</p></div>
+<div class="listingblock">
+<div class="title">Receiving a response using await</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/"</span>),
+<span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">gun:await</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ {<span style="color: #FF6600">response</span>, <span style="color: #FF6600">fin</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
+ <span style="color: #FF6600">no_data</span>;
+ {<span style="color: #FF6600">response</span>, <span style="color: #FF6600">nofin</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Body</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:await_body</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>),
+ <span style="font-weight: bold"><span style="color: #000000">io:format</span></span>(<span style="color: #FF0000">"~s~n"</span>, [<span style="color: #009900">Body</span>])
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_handling_streams_pushed_by_the_server">Handling streams pushed by the server</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The HTTP/2 protocol allows the server to push more than one
+resource for every request. It will start sending those
+extra resources before it starts sending the response itself,
+so Gun will send you <code>gun_push</code> messages before <code>gun_response</code>
+when that happens.</p></div>
+<div class="paragraph"><p>You can safely choose to ignore <code>gun_push</code> messages, or
+you can handle them. If you do, you can either receive the
+messages directly or use <em>await</em> functions.</p></div>
+<div class="paragraph"><p>The <code>gun_push</code> message contains both the new stream reference
+and the stream reference of the original request.</p></div>
+<div class="listingblock">
+<div class="title">Receiving a pushed response using receive</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
+ {<span style="color: #FF6600">gun_push</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">OriginalStreamRef</span>, <span style="color: #009900">PushedStreamRef</span>,
+ <span style="color: #009900">Method</span>, <span style="color: #009900">Host</span>, <span style="color: #009900">Path</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">enjoy</span></span>()
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If you use the <code>gun:await/{2,3,4}</code> function, however, Gun
+will use the original reference to identify the message but
+will return a tuple that doesn&#8217;t contain it.</p></div>
+<div class="listingblock">
+<div class="title">Receiving a pushed response using await</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">push</span>, <span style="color: #009900">PushedStreamRef</span>, <span style="color: #009900">Method</span>, <span style="color: #009900">Host</span>, <span style="color: #009900">Path</span>, <span style="color: #009900">Headers</span>}
+ <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:await</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">OriginalStreamRef</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The <code>PushedStreamRef</code> variable can then be used with <code>gun:await_body/{2,3,4}</code>
+if needed.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_flushing_unwanted_messages">Flushing unwanted messages</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Gun provides the function <code>gun:flush/1</code> to quickly get rid
+of unwanted messages sitting in the process mailbox. You
+can use it to get rid of all messages related to a connection,
+or just the messages related to a stream.</p></div>
+<div class="listingblock">
+<div class="title">Flush all messages from a Gun connection</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:flush</span></span>(<span style="color: #009900">ConnPid</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="listingblock">
+<div class="title">Flush all messages from a specific stream</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:flush</span></span>(<span style="color: #009900">StreamRef</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_redirecting_responses_to_a_different_process">Redirecting responses to a different process</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Gun allows you to specify which process will handle responses
+to a request via the <code>reply_to</code> request option.</p></div>
+<div class="listingblock">
+<div class="title">GET "/organizations/ninenines" to a different process</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">StreamRef</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">gun:get</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/organizations/ninenines"</span>, [],
+ #{<span style="color: #0000FF">reply_to</span> <span style="color: #990000">=&gt;</span> <span style="color: #009900">Pid</span>})<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+
+
+
<nav style="margin:1em 0">
diff --git a/docs/en/gun/1.0/guide/index.html b/docs/en/gun/1.0/guide/index.html
index 8ad8284c..d243d71c 100644
--- a/docs/en/gun/1.0/guide/index.html
+++ b/docs/en/gun/1.0/guide/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: Gun User Guide</title>
@@ -67,38 +67,38 @@
<h1 class="lined-header"><span>Gun User Guide</span></h1>
-<div class="ulist"><ul>
-<li>
-<p>
-<a href="introduction/">Introduction</a>
-</p>
-</li>
-<li>
-<p>
-<a href="start/">Starting and stopping</a>
-</p>
-</li>
-<li>
-<p>
-<a href="protocols/">Supported protocols</a>
-</p>
-</li>
-<li>
-<p>
-<a href="connect/">Connection</a>
-</p>
-</li>
-<li>
-<p>
-<a href="http/">Using HTTP</a>
-</p>
-</li>
-<li>
-<p>
-<a href="websocket/">Using Websocket</a>
-</p>
-</li>
-</ul></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="introduction/">Introduction</a>
+</p>
+</li>
+<li>
+<p>
+<a href="start/">Starting and stopping</a>
+</p>
+</li>
+<li>
+<p>
+<a href="protocols/">Supported protocols</a>
+</p>
+</li>
+<li>
+<p>
+<a href="connect/">Connection</a>
+</p>
+</li>
+<li>
+<p>
+<a href="http/">Using HTTP</a>
+</p>
+</li>
+<li>
+<p>
+<a href="websocket/">Using Websocket</a>
+</p>
+</li>
+</ul></div>
diff --git a/docs/en/gun/1.0/guide/introduction/index.html b/docs/en/gun/1.0/guide/introduction/index.html
index 46d1fc33..271dfbc9 100644
--- a/docs/en/gun/1.0/guide/introduction/index.html
+++ b/docs/en/gun/1.0/guide/introduction/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: Introduction</title>
@@ -67,46 +67,49 @@
<h1 class="lined-header"><span>Introduction</span></h1>
-<div class="paragraph"><p>Gun is an Erlang HTTP client with support for HTTP/1.1, HTTP/2 and Websocket.</p></div>
-<div class="sect1">
-<h2 id="_prerequisites">Prerequisites</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Knowledge of Erlang, but also of the HTTP/1.1, HTTP/2 and Websocket
-protocols is required in order to read this guide.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_supported_platforms">Supported platforms</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Gun is tested and supported on Linux.</p></div>
-<div class="paragraph"><p>Gun is developed for Erlang 18+.</p></div>
-<div class="paragraph"><p>Gun may be compiled on earlier Erlang versions with small source code
-modifications but there is no guarantee that it will work as intended.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_conventions">Conventions</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>In the HTTP protocol, the method name is case sensitive. All standard
-method names are uppercase.</p></div>
-<div class="paragraph"><p>Header names are case insensitive. Gun converts all the header names
-to lowercase, and expects your application to provide lowercase header
-names.</p></div>
-<div class="paragraph"><p>The same applies to any other case insensitive value.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_versioning">Versioning</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Gun uses [Semantic Versioning 2.0.0](<a href="http://semver.org/">http://semver.org/</a>).</p></div>
-</div>
-</div>
+<div class="paragraph"><p>Gun is an Erlang HTTP client with support for HTTP/1.1, HTTP/2 and Websocket.</p></div>
+<div class="sect1">
+<h2 id="_prerequisites">Prerequisites</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Knowledge of Erlang, but also of the HTTP/1.1, HTTP/2 and Websocket
+protocols is required in order to read this guide.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_supported_platforms">Supported platforms</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Gun is tested and supported on Linux.</p></div>
+<div class="paragraph"><p>Gun is developed for Erlang 18+.</p></div>
+<div class="paragraph"><p>Gun may be compiled on earlier Erlang versions with small source code
+modifications but there is no guarantee that it will work as intended.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_conventions">Conventions</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>In the HTTP protocol, the method name is case sensitive. All standard
+method names are uppercase.</p></div>
+<div class="paragraph"><p>Header names are case insensitive. Gun converts all the header names
+to lowercase, and expects your application to provide lowercase header
+names.</p></div>
+<div class="paragraph"><p>The same applies to any other case insensitive value.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_versioning">Versioning</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Gun uses [Semantic Versioning 2.0.0](<a href="http://semver.org/">http://semver.org/</a>).</p></div>
+</div>
+</div>
+
+
+
<nav style="margin:1em 0">
diff --git a/docs/en/gun/1.0/guide/protocols/index.html b/docs/en/gun/1.0/guide/protocols/index.html
index 38b05bfd..36f9b62f 100644
--- a/docs/en/gun/1.0/guide/protocols/index.html
+++ b/docs/en/gun/1.0/guide/protocols/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: Supported protocols</title>
@@ -67,265 +67,268 @@
<h1 class="lined-header"><span>Supported protocols</span></h1>
-<div class="paragraph"><p>This chapter describes the protocols supported and the
-operations available to them.</p></div>
-<div class="sect1">
-<h2 id="_http_1_1">HTTP/1.1</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>HTTP/1.1 is a text request-response protocol. The client
-sends a request, the server sends back a response.</p></div>
-<div class="paragraph"><p>Gun provides convenience functions for performing GET, HEAD,
-OPTIONS, POST, PATCH, PUT, and DELETE requests. All these
-functions are aliases of <code>gun:request/{4,5,6}</code> for each respective
-methods. Gun also provides a <code>gun:data/4</code> function for streaming
-the request body.</p></div>
-<div class="paragraph"><p>Gun will send a <code>gun_response</code> message for every response
-received, followed by zero or more <code>gun_data</code> messages for
-the response body. If something goes wrong, a <code>gun_error</code>
-will be sent instead.</p></div>
-<div class="paragraph"><p>Gun provides convenience functions for dealing with messages.
-The <code>gun:await/{2,3,4}</code> function waits for a response to the given
-request, and the <code>gun:await_body/{2,3,4}</code> function for the
-response&#8217;s body. The <code>gun:flush/1</code> function can be used to clear all
-messages related to a request or a connection from the mailbox
-of the process.</p></div>
-<div class="paragraph"><p>The function <code>gun:cancel/2</code> can be used to silence the
-response to a request previously sent if it is no longer
-needed. When using HTTP/1.1 there is no multiplexing so
-Gun will have to receive the response fully before any
-other response can be received.</p></div>
-<div class="paragraph"><p>Finally, Gun can upgrade an HTTP/1.1 connection to Websocket.
-It provides the <code>gun:ws_upgrade/{2,3,4}</code> function for that
-purpose. A <code>gun_ws_upgrade</code> message will be sent on success;
-a <code>gun_response</code> message otherwise.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_http_2">HTTP/2</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>HTTP/2 is a binary protocol based on HTTP, compatible with
-the HTTP semantics, that reduces the complexity of parsing
-requests and responses, compresses the HTTP headers and
-allows the server to push multiple responses to a single
-request.</p></div>
-<div class="paragraph"><p>The HTTP/2 interface is very similar to HTTP/1.1, so this
-section instead focuses on the differences in the interface
-for the two protocols.</p></div>
-<div class="paragraph"><p>Because a HTTP/2 server can push multiple responses to a
-single request, Gun might send <code>gun_push</code> messages for
-every push received. They can be ignored safely if they
-are not needed.</p></div>
-<div class="paragraph"><p>The <code>gun:cancel/2</code> function will use the HTTP/2 stream
-cancellation mechanism which allows Gun to inform the
-server to stop sending a response for this particular
-request, saving resources.</p></div>
-<div class="paragraph"><p>It is not possible to upgrade an HTTP/2 connection to Websocket
-due to protocol limitations.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_websocket">Websocket</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Websocket is a binary protocol built on top of HTTP that
-allows asynchronous concurrent communication between the
-client and the server. A Websocket server can push data to
-the client at any time.</p></div>
-<div class="paragraph"><p>Websocket is only available as a connection upgrade over
-an HTTP/1.1 connection.</p></div>
-<div class="paragraph"><p>Once the Websocket connection is established, the only
-operation available on this connection is sending Websocket
-frames using <code>gun:ws_send/2</code>.</p></div>
-<div class="paragraph"><p>Gun will send a <code>gun_ws</code> message for every frame received.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_summary">Summary</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>The two following tables summarize the supported operations
-and the messages Gun sends depending on the connection&#8217;s
-current protocol.</p></div>
-<div class="tableblock">
-<table rules="all"
-width="100%"
-frame="border"
-cellspacing="0" cellpadding="4">
-<col width="25%" />
-<col width="25%" />
-<col width="25%" />
-<col width="25%" />
-<thead>
-<tr>
-<th align="left" valign="top"> Operation </th>
-<th align="center" valign="top"> HTTP/1.1 </th>
-<th align="center" valign="top"> HTTP/2 </th>
-<th align="center" valign="top"> Websocket</th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td align="left" valign="top"><p class="table">delete</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">get</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">head</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">options</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">patch</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">post</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">put</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">request</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">data</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">await</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">await_body</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">flush</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">cancel</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">ws_upgrade</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">ws_send</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-</tr>
-</tbody>
-</table>
-</div>
-<div class="tableblock">
-<table rules="all"
-width="100%"
-frame="border"
-cellspacing="0" cellpadding="4">
-<col width="25%" />
-<col width="25%" />
-<col width="25%" />
-<col width="25%" />
-<thead>
-<tr>
-<th align="left" valign="top"> Message </th>
-<th align="center" valign="top"> HTTP/1.1 </th>
-<th align="center" valign="top"> HTTP/2 </th>
-<th align="center" valign="top"> Websocket</th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td align="left" valign="top"><p class="table">gun_push</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">gun_response</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">gun_data</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">gun_error (StreamRef)</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">gun_error</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">gun_ws_upgrade</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-</tr>
-<tr>
-<td align="left" valign="top"><p class="table">gun_ws</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-<td align="center" valign="top"><p class="table">no</p></td>
-<td align="center" valign="top"><p class="table">yes</p></td>
-</tr>
-</tbody>
-</table>
-</div>
-</div>
-</div>
+<div class="paragraph"><p>This chapter describes the protocols supported and the
+operations available to them.</p></div>
+<div class="sect1">
+<h2 id="_http_1_1">HTTP/1.1</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>HTTP/1.1 is a text request-response protocol. The client
+sends a request, the server sends back a response.</p></div>
+<div class="paragraph"><p>Gun provides convenience functions for performing GET, HEAD,
+OPTIONS, POST, PATCH, PUT, and DELETE requests. All these
+functions are aliases of <code>gun:request/{4,5,6}</code> for each respective
+methods. Gun also provides a <code>gun:data/4</code> function for streaming
+the request body.</p></div>
+<div class="paragraph"><p>Gun will send a <code>gun_response</code> message for every response
+received, followed by zero or more <code>gun_data</code> messages for
+the response body. If something goes wrong, a <code>gun_error</code>
+will be sent instead.</p></div>
+<div class="paragraph"><p>Gun provides convenience functions for dealing with messages.
+The <code>gun:await/{2,3,4}</code> function waits for a response to the given
+request, and the <code>gun:await_body/{2,3,4}</code> function for the
+response&#8217;s body. The <code>gun:flush/1</code> function can be used to clear all
+messages related to a request or a connection from the mailbox
+of the process.</p></div>
+<div class="paragraph"><p>The function <code>gun:cancel/2</code> can be used to silence the
+response to a request previously sent if it is no longer
+needed. When using HTTP/1.1 there is no multiplexing so
+Gun will have to receive the response fully before any
+other response can be received.</p></div>
+<div class="paragraph"><p>Finally, Gun can upgrade an HTTP/1.1 connection to Websocket.
+It provides the <code>gun:ws_upgrade/{2,3,4}</code> function for that
+purpose. A <code>gun_ws_upgrade</code> message will be sent on success;
+a <code>gun_response</code> message otherwise.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_http_2">HTTP/2</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>HTTP/2 is a binary protocol based on HTTP, compatible with
+the HTTP semantics, that reduces the complexity of parsing
+requests and responses, compresses the HTTP headers and
+allows the server to push multiple responses to a single
+request.</p></div>
+<div class="paragraph"><p>The HTTP/2 interface is very similar to HTTP/1.1, so this
+section instead focuses on the differences in the interface
+for the two protocols.</p></div>
+<div class="paragraph"><p>Because a HTTP/2 server can push multiple responses to a
+single request, Gun might send <code>gun_push</code> messages for
+every push received. They can be ignored safely if they
+are not needed.</p></div>
+<div class="paragraph"><p>The <code>gun:cancel/2</code> function will use the HTTP/2 stream
+cancellation mechanism which allows Gun to inform the
+server to stop sending a response for this particular
+request, saving resources.</p></div>
+<div class="paragraph"><p>It is not possible to upgrade an HTTP/2 connection to Websocket
+due to protocol limitations.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_websocket">Websocket</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Websocket is a binary protocol built on top of HTTP that
+allows asynchronous concurrent communication between the
+client and the server. A Websocket server can push data to
+the client at any time.</p></div>
+<div class="paragraph"><p>Websocket is only available as a connection upgrade over
+an HTTP/1.1 connection.</p></div>
+<div class="paragraph"><p>Once the Websocket connection is established, the only
+operation available on this connection is sending Websocket
+frames using <code>gun:ws_send/2</code>.</p></div>
+<div class="paragraph"><p>Gun will send a <code>gun_ws</code> message for every frame received.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_summary">Summary</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The two following tables summarize the supported operations
+and the messages Gun sends depending on the connection&#8217;s
+current protocol.</p></div>
+<div class="tableblock">
+<table rules="all"
+width="100%"
+frame="border"
+cellspacing="0" cellpadding="4">
+<col width="25%" />
+<col width="25%" />
+<col width="25%" />
+<col width="25%" />
+<thead>
+<tr>
+<th align="left" valign="top"> Operation </th>
+<th align="center" valign="top"> HTTP/1.1 </th>
+<th align="center" valign="top"> HTTP/2 </th>
+<th align="center" valign="top"> Websocket</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td align="left" valign="top"><p class="table">delete</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">get</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">head</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">options</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">patch</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">post</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">put</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">request</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">data</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">await</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">await_body</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">flush</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">cancel</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">ws_upgrade</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">ws_send</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="tableblock">
+<table rules="all"
+width="100%"
+frame="border"
+cellspacing="0" cellpadding="4">
+<col width="25%" />
+<col width="25%" />
+<col width="25%" />
+<col width="25%" />
+<thead>
+<tr>
+<th align="left" valign="top"> Message </th>
+<th align="center" valign="top"> HTTP/1.1 </th>
+<th align="center" valign="top"> HTTP/2 </th>
+<th align="center" valign="top"> Websocket</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td align="left" valign="top"><p class="table">gun_push</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">gun_response</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">gun_data</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">gun_error (StreamRef)</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">gun_error</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">gun_ws_upgrade</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">gun_ws</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+<td align="center" valign="top"><p class="table">no</p></td>
+<td align="center" valign="top"><p class="table">yes</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
+</div>
+
+
+
<nav style="margin:1em 0">
diff --git a/docs/en/gun/1.0/guide/start/index.html b/docs/en/gun/1.0/guide/start/index.html
index b0345edf..e7df8d53 100644
--- a/docs/en/gun/1.0/guide/start/index.html
+++ b/docs/en/gun/1.0/guide/start/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: Starting and stopping</title>
@@ -67,84 +67,91 @@
<h1 class="lined-header"><span>Starting and stopping</span></h1>
-<div class="paragraph"><p>This chapter describes how to start and stop the Gun application.</p></div>
-<div class="sect1">
-<h2 id="_setting_up">Setting up</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Before Gun can be used it needs to be in Erlang&#8217;s <code>ERL_LIBS</code> path variable.
-If you use <code>erlang.mk</code> or a similar build tool, you only need to specify
-Gun as a dependency to your application and the tool will take care
-of downloading Gun and setting up paths.</p></div>
-<div class="paragraph"><p>With <code>erlang.mk</code> this is done by adding <code>gun</code> to the <code>DEPS</code> variable
-in your Makefile.</p></div>
-<div class="listingblock">
-<div class="title">Adding Gun as an erlang.mk dependency</div>
-<div class="content"></div></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_starting">Starting</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Gun is an <em>OTP application</em>. It needs to be started before you can
-use it.</p></div>
-<div class="listingblock">
-<div class="title">Starting Gun in an Erlang shell</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #993399">1</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #000000">application:ensure_all_started</span></span>(<span style="color: #FF6600">gun</span>)<span style="color: #990000">.</span>
-{<span style="color: #FF6600">ok</span>,[<span style="color: #FF6600">ranch</span>,<span style="color: #FF6600">crypto</span>,<span style="color: #FF6600">cowlib</span>,<span style="color: #FF6600">asn1</span>,<span style="color: #FF6600">public_key</span>,<span style="color: #FF6600">ssl</span>,<span style="color: #FF6600">gun</span>]}</tt></pre></div></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_stopping">Stopping</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>You can stop Gun using the <code>application:stop/1</code> function, however
-only Gun will be stopped. This is the equivalent of <code>application:start/1</code>.
-The <code>application_ensure_all_started/1</code> function has no equivalent for
-stopping all applications.</p></div>
-<div class="listingblock">
-<div class="title">Stopping Gun</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">application:stop</span></span>(<span style="color: #FF6600">gun</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_using_gun_with_releases">Using Gun with releases</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>An <em>OTP release</em> starts applications automatically. All you need
-to do is to set up your application resource file so that Gun can
-be included in the release. The application resource file can be
-found in <code>ebin/your_application.app</code>, or in <code>src/your_application.app.src</code>
-if you are using a build tool like <code>erlang.mk</code>.</p></div>
-<div class="paragraph"><p>The key you need to change is the <code>applications</code> key. By default
-it only includes <code>kernel</code> and <code>stdlib</code>. You need to add <code>gun</code> to
-that list.</p></div>
-<div class="listingblock">
-<div class="title">Adding Gun to the application resource file</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt>{<span style="color: #FF6600">applications</span>, [
- <span style="color: #FF6600">kernel</span>,
- <span style="color: #FF6600">stdlib</span>,
- <span style="color: #FF6600">gun</span>
-]}</tt></pre></div></div>
-<div class="paragraph"><p>Do not put an extra comma at the end, the comma is a separator
-between the elements of the list.</p></div>
-</div>
-</div>
+<div class="paragraph"><p>This chapter describes how to start and stop the Gun application.</p></div>
+<div class="sect1">
+<h2 id="_setting_up">Setting up</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Before Gun can be used it needs to be in Erlang&#8217;s <code>ERL_LIBS</code> path variable.
+If you use <code>erlang.mk</code> or a similar build tool, you only need to specify
+Gun as a dependency to your application and the tool will take care
+of downloading Gun and setting up paths.</p></div>
+<div class="paragraph"><p>With <code>erlang.mk</code> this is done by adding <code>gun</code> to the <code>DEPS</code> variable
+in your Makefile.</p></div>
+<div class="listingblock">
+<div class="title">Adding Gun as an erlang.mk dependency</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">DEPS =</span> gun</tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_starting">Starting</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Gun is an <em>OTP application</em>. It needs to be started before you can
+use it.</p></div>
+<div class="listingblock">
+<div class="title">Starting Gun in an Erlang shell</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #993399">1</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #000000">application:ensure_all_started</span></span>(<span style="color: #FF6600">gun</span>)<span style="color: #990000">.</span>
+{<span style="color: #FF6600">ok</span>,[<span style="color: #FF6600">ranch</span>,<span style="color: #FF6600">crypto</span>,<span style="color: #FF6600">cowlib</span>,<span style="color: #FF6600">asn1</span>,<span style="color: #FF6600">public_key</span>,<span style="color: #FF6600">ssl</span>,<span style="color: #FF6600">gun</span>]}</tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_stopping">Stopping</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can stop Gun using the <code>application:stop/1</code> function, however
+only Gun will be stopped. This is the equivalent of <code>application:start/1</code>.
+The <code>application_ensure_all_started/1</code> function has no equivalent for
+stopping all applications.</p></div>
+<div class="listingblock">
+<div class="title">Stopping Gun</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">application:stop</span></span>(<span style="color: #FF6600">gun</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_using_gun_with_releases">Using Gun with releases</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>An <em>OTP release</em> starts applications automatically. All you need
+to do is to set up your application resource file so that Gun can
+be included in the release. The application resource file can be
+found in <code>ebin/your_application.app</code>, or in <code>src/your_application.app.src</code>
+if you are using a build tool like <code>erlang.mk</code>.</p></div>
+<div class="paragraph"><p>The key you need to change is the <code>applications</code> key. By default
+it only includes <code>kernel</code> and <code>stdlib</code>. You need to add <code>gun</code> to
+that list.</p></div>
+<div class="listingblock">
+<div class="title">Adding Gun to the application resource file</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">applications</span>, [
+ <span style="color: #FF6600">kernel</span>,
+ <span style="color: #FF6600">stdlib</span>,
+ <span style="color: #FF6600">gun</span>
+]}</tt></pre></div></div>
+<div class="paragraph"><p>Do not put an extra comma at the end, the comma is a separator
+between the elements of the list.</p></div>
+</div>
+</div>
+
+
+
<nav style="margin:1em 0">
diff --git a/docs/en/gun/1.0/guide/websocket/index.html b/docs/en/gun/1.0/guide/websocket/index.html
index 4f162488..b10064cf 100644
--- a/docs/en/gun/1.0/guide/websocket/index.html
+++ b/docs/en/gun/1.0/guide/websocket/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: Websocket</title>
@@ -67,134 +67,137 @@
<h1 class="lined-header"><span>Websocket</span></h1>
-<div class="paragraph"><p>This chapter describes how to use the Gun client for
-communicating with a Websocket server.</p></div>
-<div class="paragraph"><p>@todo recovering from connection failure
-reconnecting to Websocket etc.</p></div>
-<div class="sect1">
-<h2 id="_http_upgrade">HTTP upgrade</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Websocket is a protocol built on top of HTTP. To use Websocket,
-you must first request for the connection to be upgraded. Only
-HTTP/1.1 connections can be upgraded to Websocket, so you might
-need to restrict the protocol to HTTP/1.1 if you are planning
-to use Websocket over TLS.</p></div>
-<div class="paragraph"><p>You must use the <code>gun_ws:upgrade/{2,3,4}</code> function to upgrade
-to Websocket. This function can be called anytime after connection,
-so you can send HTTP requests before upgrading to Websocket.</p></div>
-<div class="listingblock">
-<div class="title">Upgrade to Websocket</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:ws_upgrade</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/websocket"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>Gun will set all the necessary headers for performing the
-Websocket upgrade, but you can specify additional headers
-if needed. For example you can request a custom sub-protocol.</p></div>
-<div class="listingblock">
-<div class="title">Upgrade to Websocket and request a protocol</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:ws_upgrade</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/websocket"</span>, [
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"sec-websocket-protocol"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"mychat"</span>}
-])<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>You can pass the Websocket options as part of the <code>gun:open/{2,3}</code>
-call when opening the connection, or using the <code>gun:ws_upgrade/4</code>.
-The fourth argument is those same options. This function call
-will crash if the options are incorrect, unlike when passing
-them through <code>gun:open/{2,3}</code>.</p></div>
-<div class="paragraph"><p>When the upgrade succeeds, a <code>gun_ws_upgrade</code> message is sent.
-If the server does not understand Websocket or refused the
-upgrade, a <code>gun_response</code> message is sent. If Gun couldn&#8217;t
-perform the upgrade due to an error (for example attempting
-to upgrade to Websocket on an HTTP/1.0 connection) then a
-<code>gun_error</code> message is sent.</p></div>
-<div class="paragraph"><p>When the server does not understand Websocket, it may send
-a meaningful response which should be processed. In the
-following example we however ignore it:</p></div>
-<div class="listingblock">
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
- {<span style="color: #FF6600">gun_ws_upgrade</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #FF6600">ok</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">upgrade_success</span></span>(<span style="color: #009900">ConnPid</span>);
- {<span style="color: #FF6600">gun_response</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #990000">_</span>, <span style="color: #990000">_</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000080">exit</span></span>({<span style="color: #FF6600">ws_upgrade_failed</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>});
- {<span style="color: #FF6600">gun_error</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">Reason</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000080">exit</span></span>({<span style="color: #FF6600">ws_upgrade_failed</span>, <span style="color: #009900">Reason</span>})
- <span style="font-style: italic"><span style="color: #9A1900">%% More clauses here as needed.</span></span>
-<span style="font-weight: bold"><span style="color: #0000FF">after</span></span> <span style="color: #993399">1000</span> <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #FF6600">timeout</span>)
-<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>Note that you shouldn&#8217;t use the <code>reply_to</code> request option
-for connections you plan to upgrade, because only the
-owner of the connection will receive messages about it.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_sending_data">Sending data</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Once the Websocket upgrade has completed successfully, you no
-longer have access to functions for performing requests. You
-can only send and receive Websocket messages.</p></div>
-<div class="paragraph"><p>Use <code>gun:ws_send/2</code> to send one or more messages to the server.</p></div>
-<div class="paragraph"><p>@todo Implement sending of N frames</p></div>
-<div class="listingblock">
-<div class="title">Send a text frame</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:ws_send</span></span>(<span style="color: #009900">ConnPid</span>, {<span style="color: #FF6600">text</span>, <span style="color: #FF0000">"Hello!"</span>})<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="listingblock">
-<div class="title">Send a text frame, a binary frame and then close the connection</div>
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:ws_send</span></span>(<span style="color: #009900">ConnPid</span>, [
- {<span style="color: #FF6600">text</span>, <span style="color: #FF0000">"Hello!"</span>},
- {<span style="font-weight: bold"><span style="color: #000080">binary</span></span>, <span style="color: #009900">BinaryValue</span>},
- <span style="color: #FF6600">close</span>
-])<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>Note that if you send a close frame, Gun will close the connection
-cleanly and will not attempt to reconnect afterwards, similar to
-calling <code>gun:shutdown/1</code>.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_receiving_data">Receiving data</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Gun sends an Erlang message to the owner process for every
-Websocket message it receives.</p></div>
-<div class="listingblock">
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
- {<span style="color: #FF6600">gun_ws</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">Frame</span>} <span style="color: #990000">-&gt;</span>
- <span style="font-weight: bold"><span style="color: #000000">handle_frame</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">Frame</span>)
-<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>@todo auto ping has not been implemented yet</p></div>
-<div class="paragraph"><p>Gun will automatically send ping messages to the server to keep
-the connection alive, however if the connection dies and Gun has
-to reconnect it will not upgrade to Websocket automatically, you
-need to perform the operation when you receive the <code>gun_error</code>
-message.</p></div>
-</div>
-</div>
+<div class="paragraph"><p>This chapter describes how to use the Gun client for
+communicating with a Websocket server.</p></div>
+<div class="paragraph"><p>@todo recovering from connection failure
+reconnecting to Websocket etc.</p></div>
+<div class="sect1">
+<h2 id="_http_upgrade">HTTP upgrade</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Websocket is a protocol built on top of HTTP. To use Websocket,
+you must first request for the connection to be upgraded. Only
+HTTP/1.1 connections can be upgraded to Websocket, so you might
+need to restrict the protocol to HTTP/1.1 if you are planning
+to use Websocket over TLS.</p></div>
+<div class="paragraph"><p>You must use the <code>gun_ws:upgrade/{2,3,4}</code> function to upgrade
+to Websocket. This function can be called anytime after connection,
+so you can send HTTP requests before upgrading to Websocket.</p></div>
+<div class="listingblock">
+<div class="title">Upgrade to Websocket</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:ws_upgrade</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/websocket"</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Gun will set all the necessary headers for performing the
+Websocket upgrade, but you can specify additional headers
+if needed. For example you can request a custom sub-protocol.</p></div>
+<div class="listingblock">
+<div class="title">Upgrade to Websocket and request a protocol</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:ws_upgrade</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #FF0000">"/websocket"</span>, [
+ {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"sec-websocket-protocol"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #FF0000">"mychat"</span>}
+])<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can pass the Websocket options as part of the <code>gun:open/{2,3}</code>
+call when opening the connection, or using the <code>gun:ws_upgrade/4</code>.
+The fourth argument is those same options. This function call
+will crash if the options are incorrect, unlike when passing
+them through <code>gun:open/{2,3}</code>.</p></div>
+<div class="paragraph"><p>When the upgrade succeeds, a <code>gun_ws_upgrade</code> message is sent.
+If the server does not understand Websocket or refused the
+upgrade, a <code>gun_response</code> message is sent. If Gun couldn&#8217;t
+perform the upgrade due to an error (for example attempting
+to upgrade to Websocket on an HTTP/1.0 connection) then a
+<code>gun_error</code> message is sent.</p></div>
+<div class="paragraph"><p>When the server does not understand Websocket, it may send
+a meaningful response which should be processed. In the
+following example we however ignore it:</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
+ {<span style="color: #FF6600">gun_ws_upgrade</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #FF6600">ok</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">upgrade_success</span></span>(<span style="color: #009900">ConnPid</span>);
+ {<span style="color: #FF6600">gun_response</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #990000">_</span>, <span style="color: #990000">_</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000080">exit</span></span>({<span style="color: #FF6600">ws_upgrade_failed</span>, <span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>});
+ {<span style="color: #FF6600">gun_error</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">StreamRef</span>, <span style="color: #009900">Reason</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000080">exit</span></span>({<span style="color: #FF6600">ws_upgrade_failed</span>, <span style="color: #009900">Reason</span>})
+ <span style="font-style: italic"><span style="color: #9A1900">%% More clauses here as needed.</span></span>
+<span style="font-weight: bold"><span style="color: #0000FF">after</span></span> <span style="color: #993399">1000</span> <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000080">exit</span></span>(<span style="color: #FF6600">timeout</span>)
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that you shouldn&#8217;t use the <code>reply_to</code> request option
+for connections you plan to upgrade, because only the
+owner of the connection will receive messages about it.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_sending_data">Sending data</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Once the Websocket upgrade has completed successfully, you no
+longer have access to functions for performing requests. You
+can only send and receive Websocket messages.</p></div>
+<div class="paragraph"><p>Use <code>gun:ws_send/2</code> to send one or more messages to the server.</p></div>
+<div class="paragraph"><p>@todo Implement sending of N frames</p></div>
+<div class="listingblock">
+<div class="title">Send a text frame</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:ws_send</span></span>(<span style="color: #009900">ConnPid</span>, {<span style="color: #FF6600">text</span>, <span style="color: #FF0000">"Hello!"</span>})<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="listingblock">
+<div class="title">Send a text frame, a binary frame and then close the connection</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">gun:ws_send</span></span>(<span style="color: #009900">ConnPid</span>, [
+ {<span style="color: #FF6600">text</span>, <span style="color: #FF0000">"Hello!"</span>},
+ {<span style="font-weight: bold"><span style="color: #000080">binary</span></span>, <span style="color: #009900">BinaryValue</span>},
+ <span style="color: #FF6600">close</span>
+])<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that if you send a close frame, Gun will close the connection
+cleanly and will not attempt to reconnect afterwards, similar to
+calling <code>gun:shutdown/1</code>.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_receiving_data">Receiving data</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Gun sends an Erlang message to the owner process for every
+Websocket message it receives.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">receive</span></span>
+ {<span style="color: #FF6600">gun_ws</span>, <span style="color: #009900">ConnPid</span>, <span style="color: #009900">Frame</span>} <span style="color: #990000">-&gt;</span>
+ <span style="font-weight: bold"><span style="color: #000000">handle_frame</span></span>(<span style="color: #009900">ConnPid</span>, <span style="color: #009900">Frame</span>)
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>@todo auto ping has not been implemented yet</p></div>
+<div class="paragraph"><p>Gun will automatically send ping messages to the server to keep
+the connection alive, however if the connection dies and Gun has
+to reconnect it will not upgrade to Websocket automatically, you
+need to perform the operation when you receive the <code>gun_error</code>
+message.</p></div>
+</div>
+</div>
+
+
+
<nav style="margin:1em 0">
diff --git a/docs/en/gun/1.0/index.html b/docs/en/gun/1.0/index.html
index d87c4243..0194031a 100644
--- a/docs/en/gun/1.0/index.html
+++ b/docs/en/gun/1.0/index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><title>https://ninenines.eu/docs/</title><link rel="canonical" href="https://ninenines.eu/docs/"/><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="refresh" content="0; url=https://ninenines.eu/docs/" /></head></html> \ No newline at end of file
+<!DOCTYPE html><html><head><title>https://ninenines.eu/docs/</title><link rel="canonical" href="https://ninenines.eu/docs/"/><meta name="robots" content="noindex"><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="refresh" content="0; url=https://ninenines.eu/docs/" /></head></html> \ No newline at end of file
diff --git a/docs/en/gun/1.0/manual/gun/index.html b/docs/en/gun/1.0/manual/gun/index.html
index 9fedee7e..aad74371 100644
--- a/docs/en/gun/1.0/manual/gun/index.html
+++ b/docs/en/gun/1.0/manual/gun/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: gun(3)</title>
@@ -67,1731 +67,1731 @@
<h1 class="lined-header"><span>gun(3)</span></h1>
-<div class="sect1">
-<h2 id="_name">Name</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>gun - asynchronous HTTP client</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_description">Description</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>The <code>gun</code> module provides an asynchronous interface for
-connecting and communicating with Web servers over HTTP,
-HTTP/2 or Websocket.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_types">Types</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="_opts_map">opts() = map()</h3>
-<div class="paragraph"><p>Configuration for the connection.</p></div>
-<div class="paragraph"><p>The following keys are defined:</p></div>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-connect_timeout &#8658; timeout()
-</dt>
-<dd>
-<p>
- Connection timeout. Defaults to <code>infinity</code>.
-</p>
-</dd>
-<dt class="hdlist1">
-http_opts &#8658; http_opts()
-</dt>
-<dd>
-<p>
- Options specific to the HTTP protocol. See below.
-</p>
-</dd>
-<dt class="hdlist1">
-http2_opts &#8658; http2_opts()
-</dt>
-<dd>
-<p>
- Options specific to the HTTP/2 protocol. See below.
-</p>
-</dd>
-<dt class="hdlist1">
-protocols &#8658; [http | http2]
-</dt>
-<dd>
-<p>
- Ordered list of preferred protocols. When the transport is tcp,
- this list must contain exactly one protocol. When the transport
- is ssl, this list must contain at least one protocol and will be
- used using the ALPN protocol negotiation method. When the server
- does not support ALPN then http will always be used. Defaults to
- [http] when the transport is tcp, and [http2, http] when the
- transport is ssl.
-</p>
-</dd>
-<dt class="hdlist1">
-retry &#8658; non_neg_integer()
-</dt>
-<dd>
-<p>
- Number of times Gun will try to reconnect on failure before giving up.
- Defaults to 5.
-</p>
-</dd>
-<dt class="hdlist1">
-retry_timeout &#8658; pos_integer()
-</dt>
-<dd>
-<p>
- Time between retries in milliseconds. Defaults to 5000.
-</p>
-</dd>
-<dt class="hdlist1">
-trace &#8658; boolean()
-</dt>
-<dd>
-<p>
- Whether to enable <code>dbg</code> tracing of the connection process. Should
- only be used during debugging. Defaults to false.
-</p>
-</dd>
-<dt class="hdlist1">
-transport &#8658; tcp | ssl
-</dt>
-<dd>
-<p>
- Whether to use SSL or plain TCP. The default varies depending on the
- port used. Port 443 defaults to ssl. All other ports default to tcp.
-</p>
-</dd>
-<dt class="hdlist1">
-transport_opts &#8658; proplists:proplist()
-</dt>
-<dd>
-<p>
- Transport options. They are TCP options or SSL options depending on
- the selected transport.
-</p>
-</dd>
-<dt class="hdlist1">
-ws_opts &#8658; ws_opts()
-</dt>
-<dd>
-<p>
- Options specific to the Websocket protocol. See below.
-</p>
-</dd>
-</dl></div>
-</div>
-<div class="sect2">
-<h3 id="_http_opts_map">http_opts() = map()</h3>
-<div class="paragraph"><p>Configuration for the HTTP protocol.</p></div>
-<div class="paragraph"><p>The following keys are defined:</p></div>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-keepalive &#8658; timeout()
-</dt>
-<dd>
-<p>
- Time between pings in milliseconds. Since the HTTP protocol has
- no standardized way to ping the server, Gun will simply send an
- empty line when the connection is idle. Gun only makes a best
- effort here as servers usually have configurable limits to drop
- idle connections. Use <code>infinity</code> to disable. Defaults to 5000.
-</p>
-</dd>
-<dt class="hdlist1">
-transform_header_name &#8658; funLowercaseName :: binary( &#8594; TransformedName :: binary()) | undefined
-</dt>
-<dd>
-<p>
- A function that will be applied to all header names before they
- are sent to the server. Gun assumes that all header names are in
- lower case. This function is useful if you, for example, need to
- re-case header names in the event that the server incorrectly
- considers header name case to be significant.
-</p>
-</dd>
-<dt class="hdlist1">
-version &#8658; <em>HTTP/1.1</em> | <em>HTTP/1.0</em>
-</dt>
-<dd>
-<p>
- HTTP version to use. Defaults to <em>HTTP/1.1</em>.
-</p>
-</dd>
-</dl></div>
-</div>
-<div class="sect2">
-<h3 id="_http2_opts_map">http2_opts() = map()</h3>
-<div class="paragraph"><p>Configuration for the HTTP/2 protocol.</p></div>
-<div class="paragraph"><p>The following keys are defined:</p></div>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-keepalive &#8658; pos_integer()
-</dt>
-<dd>
-<p>
- Time between pings in milliseconds. Defaults to 5000.
-</p>
-</dd>
-</dl></div>
-</div>
-<div class="sect2">
-<h3 id="_req_opts_map">req_opts() = map()</h3>
-<div class="paragraph"><p>Configuration for a particular request.</p></div>
-<div class="paragraph"><p>The following keys are defined:</p></div>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-reply_to &#8658; pid()
-</dt>
-<dd>
-<p>
- The pid of a process that is responsible for the response handling.
-</p>
-</dd>
-</dl></div>
-</div>
-<div class="sect2">
-<h3 id="_ws_opts_map">ws_opts() = map()</h3>
-<div class="paragraph"><p>Configuration for the Websocket protocol.</p></div>
-<div class="paragraph"><p>The following keys are defined:</p></div>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-compress &#8658; boolean()
-</dt>
-<dd>
-<p>
- Whether to enable permessage-deflate compression. This does
- not guarantee that compression will be used as it is the
- server that ultimately decides. Defaults to false.
-</p>
-</dd>
-</dl></div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_messages">Messages</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Calling functions from this module may result in the following
-messages being sent.</p></div>
-<div class="sect2">
-<h3 id="_gun_up_connpid_protocol">{gun_up, ConnPid, Protocol}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Protocol = http | http2
-</dt>
-<dd>
-<p>
-The protocol selected for this connection.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>The connection is up.</p></div>
-<div class="paragraph"><p>This message informs the owner process that the connection or
-reconnection completed.</p></div>
-<div class="paragraph"><p>The protocol selected during the connection is sent in this
-message. It can be used to determine the capabilities of the
-server.</p></div>
-<div class="paragraph"><p>Gun will now start processing the messages it received while
-waiting for the connection to be up. If this is a reconnection,
-then this may not be desirable for all requests. Those requests
-should be cancelled when the connection goes down, and any
-subsequent messages ignored.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_gun_down_connpid_protocol_reason_killedstreams_unprocessedstreams">{gun_down, ConnPid, Protocol, Reason, KilledStreams, UnprocessedStreams}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Protocol = http | http2 | ws
-</dt>
-<dd>
-<p>
-The protocol in use when the connection was lost.
-</p>
-</dd>
-<dt class="hdlist1">
-Reason = normal | closed | {error, atom()}
-</dt>
-<dd>
-<p>
-The reason for the loss of the connection.
-</p>
-</dd>
-<dt class="hdlist1">
-KilledStreams = [reference()]
-</dt>
-<dd>
-<p>
-List of streams that have been brutally terminated.
-</p>
-</dd>
-<dt class="hdlist1">
-UnprocessedStreams = [reference()]
-</dt>
-<dd>
-<p>
-List of streams that have not been processed by the server.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>The connection is down.</p></div>
-<div class="paragraph"><p>This message informs the owner process that the connection is
-currently down. Gun will automatically attempt to reconnect
-depending on the <code>retry</code> and <code>retry_timeout</code> options.</p></div>
-<div class="paragraph"><p>The reason of the termination is there for debugging purposes
-only. You should not rely on this value to know what streams
-were processed or completed.</p></div>
-<div class="paragraph"><p>The <em>killed streams</em> are the active streams that did not complete
-before the closing of the connection. Whether they can be retried
-safely depends on the protocol used and the idempotence property
-of the requests.</p></div>
-<div class="paragraph"><p>The <em>unprocessed streams</em> are streams that the server did not
-start processing yet. They may be retried safely depending on
-what streams were killed before.</p></div>
-<div class="paragraph"><p>When the connection goes back up, Gun will not attempt to retry
-requests. It will also not upgrade to Websocket automatically
-if that was the protocol in use when the connection was lost.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_gun_push_connpid_streamref_newstreamref_uri_headers">{gun_push, ConnPid, StreamRef, NewStreamRef, URI, Headers}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream initiated by the owner process.
-</p>
-</dd>
-<dt class="hdlist1">
-NewStreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream being pushed.
-</p>
-</dd>
-<dt class="hdlist1">
-URI = binary()
-</dt>
-<dd>
-<p>
-URI of the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), binary()}]
-</dt>
-<dd>
-<p>
-Headers @todo
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>A resource pushed alongside an HTTP response.</p></div>
-<div class="paragraph"><p>This message can only be sent when the protocol is HTTP/2.</p></div>
-<div class="paragraph"><p>@todo I fear we also need the scheme; resource is identified by URI
-@todo Perhaps we really should send the URI entirely, because cache
-@todo relies on URI to work and this feature is for caching&#8230;
-@todo Not sure why Method is there, spec says it is only for GET</p></div>
-</div>
-<div class="sect2">
-<h3 id="_gun_response_connpid_streamref_isfin_status_headers">{gun_response, ConnPid, StreamRef, IsFin, Status, Headers}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream initiated by the owner process.
-</p>
-</dd>
-<dt class="hdlist1">
-IsFin = fin | nofin
-</dt>
-<dd>
-<p>
-Whether this message terminates the response.
-</p>
-</dd>
-<dt class="hdlist1">
-Status = binary()
-</dt>
-<dd>
-<p>
-Status line for the response.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), binary()}]
-</dt>
-<dd>
-<p>
-Headers sent with the response.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>A response to an HTTP request.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_gun_data_connpid_streamref_isfin_data">{gun_data, ConnPid, StreamRef, IsFin, Data}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream this data belongs to.
-</p>
-</dd>
-<dt class="hdlist1">
-IsFin = fin | nofin
-</dt>
-<dd>
-<p>
-Whether this message terminates the response.
-</p>
-</dd>
-<dt class="hdlist1">
-Data = binary()
-</dt>
-<dd>
-<p>
-Data from the stream.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Data associated with a stream.</p></div>
-<div class="paragraph"><p>The stream in question can be either one initiated by the owner
-process or a stream initiated by the server through the push
-mechanism. In any case a <code>gun_response</code> or a <code>gun_push</code> message
-will be sent before any <code>gun_data</code> message.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_gun_error_connpid_streamref_reason">{gun_error, ConnPid, StreamRef, Reason}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream this error relates to.
-</p>
-</dd>
-<dt class="hdlist1">
-Reason = any()
-</dt>
-<dd>
-<p>
-Error reason.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Stream-specific error.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_gun_error_connpid_reason">{gun_error, ConnPid, Reason}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Reason = any()
-</dt>
-<dd>
-<p>
-Error reason.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>General error.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_gun_ws_upgrade_connpid_ok_headers">{gun_ws_upgrade, ConnPid, ok, Headers}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), binary()}]
-</dt>
-<dd>
-<p>
-Headers sent with the response.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Successful upgrade to the Websocket protocol.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_gun_ws_connpid_frame">{gun_ws, ConnPid, Frame}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Frame = @todo
-</dt>
-<dd>
-<p>
-Frame.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Websocket frame.</p></div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_exports">Exports</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="_open_host_port_8594_open_host_port">open(Host, Port) &#8594; open(Host, Port, [])</h3>
-<div class="paragraph"><p>Alias of <code>gun:open/3</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_open_host_port_opts_8594_ok_connpid_error_reason">open(Host, Port, Opts) &#8594; {ok, ConnPid} | {error, Reason}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-Host = inet:hostname()
-</dt>
-<dd>
-<p>
-Host to connect to.
-</p>
-</dd>
-<dt class="hdlist1">
-Port = inet:port_number()
-</dt>
-<dd>
-<p>
-Port to connect to.
-</p>
-</dd>
-<dt class="hdlist1">
-Opts = opts()
-</dt>
-<dd>
-<p>
-Options for this connection.
-</p>
-</dd>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Reason = any()
-</dt>
-<dd>
-<p>
-Error reason. @todo really any?
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Open a connection to the given host and port.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_close_connpid_8594_ok">close(ConnPid) &#8594; ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Brutally close the connection.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_shutdown_connpid_8594_ok">shutdown(ConnPid) &#8594; ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Gracefully close the connection.</p></div>
-<div class="paragraph"><p>A monitor can be used to be notified when the connection is
-effectively closed.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_delete_connpid_path_8594_delete_connpid_path">delete(ConnPid, Path) &#8594; delete(ConnPid, Path, [], #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:delete/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_delete_connpid_path_headers_8594_delete_connpid_path_headers">delete(ConnPid, Path, Headers) &#8594; delete(ConnPid, Path, Headers, #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:delete/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_delete_connpid_path_headers_reqopts_8594_streamref">delete(ConnPid, Path, Headers, ReqOpts) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-ReqOpts = req_opts()
-</dt>
-<dd>
-<p>
-Request options.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Delete a resource.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_get_connpid_path_8594_get_connpid_path">get(ConnPid, Path) &#8594; get(ConnPid, Path, [], #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:get/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_get_connpid_path_headers_8594_get_connpid_path_headers">get(ConnPid, Path, Headers) &#8594; get(ConnPid, Path, Headers, #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:get/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_get_connpid_path_headers_reqopts_8594_streamref">get(ConnPid, Path, Headers, ReqOpts) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-ReqOpts = req_opts()
-</dt>
-<dd>
-<p>
-Request options.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Get a resource.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_head_connpid_path_8594_head_connpid_path">head(ConnPid, Path) &#8594; head(ConnPid, Path, [], #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:head/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_head_connpid_path_headers_8594_head_connpid_path_headers">head(ConnPid, Path, Headers) &#8594; head(ConnPid, Path, Headers, #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:head/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_head_connpid_path_headers_reqopts_8594_streamref">head(ConnPid, Path, Headers, ReqOpts) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-ReqOpts = req_opts()
-</dt>
-<dd>
-<p>
-Request options.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Get headers of a resource.</p></div>
-<div class="paragraph"><p>This function performs the same operation as <code>get/{2,3}</code> except
-the server will not send the resource representation, only the
-response&#8217;s status line and headers.</p></div>
-<div class="paragraph"><p>While servers should send the same headers they would if the
-request was a GET, like <code>content-length</code>, it is not always
-the case and differences may exist.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_options_connpid_path_8594_options_connpid_path">options(ConnPid, Path) &#8594; options(ConnPid, Path, [], #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:options/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_options_connpid_path_headers_8594_options_connpid_path_headers">options(ConnPid, Path, Headers) &#8594; options(ConnPid, Path, Headers, #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:options/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_options_connpid_path_headers_reqopts_8594_streamref">options(ConnPid, Path, Headers, ReqOpts) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-ReqOpts = req_opts()
-</dt>
-<dd>
-<p>
-Request options.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Obtain information about the capabilities of the server or of a resource.</p></div>
-<div class="paragraph"><p>The special path <code>"*"</code> can be used to obtain information about
-the server as a whole. Any other path will return information
-about the resource only.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_patch_connpid_path_headers_8594_streamref">patch(ConnPid, Path, Headers) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Request that a set of changes be applied to the resource.</p></div>
-<div class="paragraph"><p>This function expects either <code>content-length</code> or <code>content-type</code>
-to be set to know a body is going to be sent afterwards.
-Gun will assume the request has no body otherwise. It is
-highly recommended to set both when possible.</p></div>
-<div class="paragraph"><p>The body sent in this request should be a patch document
-with instructions on how to update the resource.</p></div>
-<div class="paragraph"><p>You can use the <code>gun:data/4</code> function to send the body, if any.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_patch_connpid_path_headers_body_8594_patch_connpid_path_headers_body">patch(ConnPid, Path, Headers, Body) &#8594; patch(ConnPid, Path, Headers, Body, #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:patch/5</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_patch_connpid_path_headers_body_reqopts_8594_streamref">patch(ConnPid, Path, Headers, Body, ReqOpts) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-Body = iodata()
-</dt>
-<dd>
-<p>
-Body of the request.
-</p>
-</dd>
-<dt class="hdlist1">
-ReqOpts = req_opts()
-</dt>
-<dd>
-<p>
-Request options.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Request that a set of changes be applied to the resource.</p></div>
-<div class="paragraph"><p>It is highly recommended to set the <code>content-type</code> header
-to inform the server what media type the body contains.
-Gun will automatically set the <code>content-length</code> header.</p></div>
-<div class="paragraph"><p>The body sent in this request should be a patch document
-with instructions on how to update the resource.</p></div>
-<div class="paragraph"><p>The complete request is sent when calling this function.
-It is not possible to stream more of the body after
-calling it.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_post_connpid_path_headers_8594_streamref">post(ConnPid, Path, Headers) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Process the enclosed representation according to the resource&#8217;s own semantics.</p></div>
-<div class="paragraph"><p>This function expects either <code>content-length</code> or <code>content-type</code>
-to be set to know a body is going to be sent afterwards.
-Gun will assume the request has no body otherwise. It is
-highly recommended to set both when possible.</p></div>
-<div class="paragraph"><p>The body sent in this request will be processed
-according to the resource&#8217;s own semantics. A new
-resource may be created as a result, and may be
-located at a different URI.</p></div>
-<div class="paragraph"><p>You can use the <code>gun:data/4</code> function to send the body, if any.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_post_connpid_path_headers_body_8594_post_connpid_path_headers_body">post(ConnPid, Path, Headers, Body) &#8594; post(ConnPid, Path, Headers, Body, #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:post/5</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_post_connpid_path_headers_body_reqopts_8594_streamref">post(ConnPid, Path, Headers, Body, ReqOpts) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-Body = iodata()
-</dt>
-<dd>
-<p>
-Body of the request.
-</p>
-</dd>
-<dt class="hdlist1">
-ReqOpts = req_opts()
-</dt>
-<dd>
-<p>
-Request options.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Process the enclosed representation according to the resource&#8217;s own semantics.</p></div>
-<div class="paragraph"><p>It is highly recommended to set the <code>content-type</code> header
-to inform the server what media type the body contains.
-Gun will automatically set the <code>content-length</code> header.</p></div>
-<div class="paragraph"><p>The body sent in this request will be processed
-according to the resource&#8217;s own semantics. A new
-resource may be created as a result, and may be
-located at a different URI.</p></div>
-<div class="paragraph"><p>The complete request is sent when calling this function.
-It is not possible to stream more of the body after
-calling it.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_put_connpid_path_headers_8594_streamref">put(ConnPid, Path, Headers) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Create or replace a resource.</p></div>
-<div class="paragraph"><p>The body of the request is the entire representation of the resource.</p></div>
-<div class="paragraph"><p>This function expects either <code>content-length</code> or <code>content-type</code>
-to be set to know a body is going to be sent afterwards.
-Gun will assume the request has no body otherwise. It is
-highly recommended to set both when possible.</p></div>
-<div class="paragraph"><p>You can use the <code>gun:data/4</code> function to send the body, if any.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_put_connpid_path_headers_body_8594_put_connpid_path_headers_body">put(ConnPid, Path, Headers, Body) &#8594; put(ConnPid, Path, Headers, Body, #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:put/5</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_put_connpid_path_headers_body_reqopts_8594_streamref">put(ConnPid, Path, Headers, Body, ReqOpts) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-Body = iodata()
-</dt>
-<dd>
-<p>
-Body of the request.
-</p>
-</dd>
-<dt class="hdlist1">
-ReqOpts = req_opts()
-</dt>
-<dd>
-<p>
-Request options.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Create or replace a resource.</p></div>
-<div class="paragraph"><p>The body of the request is the entire representation of the resource.</p></div>
-<div class="paragraph"><p>It is highly recommended to set the <code>content-type</code> header
-to inform the server what media type the body contains.
-Gun will automatically set the <code>content-length</code> header.</p></div>
-<div class="paragraph"><p>The complete request is sent when calling this function.
-It is not possible to stream more of the body after
-calling it.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_request_connpid_method_path_headers_8594_streamref">request(ConnPid, Method, Path, Headers) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Method = iodata()
-</dt>
-<dd>
-<p>
-Request method.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path of the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Perform the given request.</p></div>
-<div class="paragraph"><p>This is a general purpose function that should only be used
-when existing method-specific functions don&#8217;t apply.</p></div>
-<div class="paragraph"><p>This function expects either <code>content-length</code> or <code>content-type</code>
-to be set to know a body is going to be sent afterwards.
-Gun will assume the request has no body otherwise. It is
-highly recommended to set both when possible.</p></div>
-<div class="paragraph"><p>You can use the <code>gun:data/4</code> function to send the body, if any.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_request_connpid_method_path_headers_body_8594_request_connpid_method_path_headers_body">request(ConnPid, Method, Path, Headers, Body) &#8594; request(ConnPid, Method, Path, Headers, Body, #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:request/6</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_request_connpid_method_path_headers_body_reqopts_8594_streamref">request(ConnPid, Method, Path, Headers, Body, ReqOpts) &#8594; StreamRef</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Method = iodata()
-</dt>
-<dd>
-<p>
-Request method.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path of the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-Body = iodata()
-</dt>
-<dd>
-<p>
-Body of the request.
-</p>
-</dd>
-<dt class="hdlist1">
-ReqOpts = req_opts()
-</dt>
-<dd>
-<p>
-Request options.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream for this request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Perform the given request.</p></div>
-<div class="paragraph"><p>This is a general purpose function that should only be used
-when existing method-specific functions don&#8217;t apply.</p></div>
-<div class="paragraph"><p>It is highly recommended to set the <code>content-type</code> header
-to inform the server what media type the body contains.
-Gun will automatically set the <code>content-length</code> header.</p></div>
-<div class="paragraph"><p>The complete request is sent when calling this function.
-It is not possible to stream more of the body after
-calling it.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_data_connpid_streamref_isfin_data_8594_ok">data(ConnPid, StreamRef, IsFin, Data) &#8594; ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream this data belongs to.
-</p>
-</dd>
-<dt class="hdlist1">
-IsFin = fin | nofin
-</dt>
-<dd>
-<p>
-Whether this message terminates the request.
-</p>
-</dd>
-<dt class="hdlist1">
-Data = iodata()
-</dt>
-<dd>
-<p>
-Data to be sent with the request.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Stream the body of a request.</p></div>
-<div class="paragraph"><p>@todo empty chunks</p></div>
-<div class="paragraph"><p>This function can only be used if the request identified by
-<code>StreamRef</code> came with headers indicating the presence of a
-body and that body not being given when creating the request.</p></div>
-<div class="paragraph"><p>All calls to this function must use <code>nofin</code> except for the
-last which must use <code>fin</code> to indicate the end of the request
-body.</p></div>
-<div class="paragraph"><p>Empty data is allowed regardless of the value of <code>IsFin</code>.
-Gun will not send empty data chunks unless required to
-indicate the request body is finished, however.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_await_connpid_streamref_8594_await_connpid_streamref_5000_monitorref">await(ConnPid, StreamRef) &#8594; await(ConnPid, StreamRef, 5000, MonitorRef)</h3>
-<div class="paragraph"><p>Alias of <code>gun:await/4</code>.</p></div>
-<div class="paragraph"><p>A monitor <code>MonitorRef</code> is automatically created for the duration of
-this call and an error will be returned if the Gun connection process
-terminates.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_await_connpid_streamref_monitorref_8594_await_connpid_streamref_5000_monitorref">await(ConnPid, StreamRef, MonitorRef) &#8594; await(ConnPid, StreamRef, 5000, MonitorRef)</h3>
-<div class="paragraph"><p>Alias of <code>gun:await/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_await_connpid_streamref_timeout_8594_await_connpid_streamref_timeout_monitorref">await(ConnPid, StreamRef, Timeout) &#8594; await(ConnPid, StreamRef, Timeout, MonitorRef)</h3>
-<div class="paragraph"><p>Alias of <code>gun:await/4</code>.</p></div>
-<div class="paragraph"><p>A monitor <code>MonitorRef</code> is automatically created for the duration of
-this call and an error will be returned if the Gun connection process
-terminates.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_await_connpid_streamref_timeout_monitorref_8594_tuple_8201_8212_8201_see_below">await(ConnPid, StreamRef, Timeout, MonitorRef) &#8594; tuple()&#8201;&#8212;&#8201;see below</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream to await messages from.
-</p>
-</dd>
-<dt class="hdlist1">
-Timeout = timeout()
-</dt>
-<dd>
-<p>
-How long this function will wait for messages.
-</p>
-</dd>
-<dt class="hdlist1">
-MonitorRef = reference()
-</dt>
-<dd>
-<p>
-Monitor reference for the Gun connection process.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Wait for a response message.</p></div>
-<div class="paragraph"><p>This function can be used when a synchronous handling of
-responses is desired. It will only return when a message
-for the given stream is received, on error or on timeout.</p></div>
-<div class="paragraph"><p>The return values are described in the next few subsections.</p></div>
-<div class="sect3">
-<h4 id="_response_isfin_status_headers">{response, IsFin, Status, Headers}</h4>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-IsFin = fin | nofin
-</dt>
-<dd>
-<p>
-Whether this message terminates the response.
-</p>
-</dd>
-<dt class="hdlist1">
-Status = binary()
-</dt>
-<dd>
-<p>
-Status line for the response.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), binary()}]
-</dt>
-<dd>
-<p>
-Headers sent with the response.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Equivalent of a <code>gun_response</code> message.</p></div>
-</div>
-<div class="sect3">
-<h4 id="_data_isfin_data">{data, IsFin, Data}</h4>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-IsFin = fin | nofin
-</dt>
-<dd>
-<p>
-Whether this message terminates the response.
-</p>
-</dd>
-<dt class="hdlist1">
-Data = binary()
-</dt>
-<dd>
-<p>
-Data from the stream.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Equivalent of a <code>gun_data</code> message.</p></div>
-</div>
-<div class="sect3">
-<h4 id="_push_newstreamref_uri_headers">{push, NewStreamRef, URI, Headers}</h4>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-NewStreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream being pushed.
-</p>
-</dd>
-<dt class="hdlist1">
-URI = binary()
-</dt>
-<dd>
-<p>
-URI of the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), binary()}]
-</dt>
-<dd>
-<p>
-Headers @todo
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Equivalent of a <code>gun_push</code> message.</p></div>
-<div class="paragraph"><p>@todo Same changes as gun_push</p></div>
-</div>
-<div class="sect3">
-<h4 id="_error_reason">{error, Reason}</h4>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-Reason = any()
-</dt>
-<dd>
-<p>
-Error reason. @todo any?
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Equivalent of a <code>gun_error</code> message.</p></div>
-<div class="paragraph"><p>@todo I think we want to distinguish a stream error, a general error,
-@todo a DOWN and a timeout error</p></div>
-</div>
-</div>
-<div class="sect2">
-<h3 id="_await_body_connpid_streamref_8594_await_body_connpid_streamref_5000_monitorref">await_body(ConnPid, StreamRef) &#8594; await_body(ConnPid, StreamRef, 5000, MonitorRef)</h3>
-<div class="paragraph"><p>Alias of <code>gun:await_body/4</code>.</p></div>
-<div class="paragraph"><p>A monitor <code>MonitorRef</code> is automatically created for the duration of
-this call and an error will be returned if the Gun connection process
-terminates.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_await_body_connpid_streamref_monitorref_8594_await_body_connpid_streamref_5000_monitorref">await_body(ConnPid, StreamRef, MonitorRef) &#8594; await_body(ConnPid, StreamRef, 5000, MonitorRef)</h3>
-<div class="paragraph"><p>Alias of <code>gun:await_body/4</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_await_body_connpid_streamref_timeout_8594_await_body_connpid_streamref_timeout_monitorref">await_body(ConnPid, StreamRef, Timeout) &#8594; await_body(ConnPid, StreamRef, Timeout, MonitorRef)</h3>
-<div class="paragraph"><p>Alias of <code>gun:await_body/4</code>.</p></div>
-<div class="paragraph"><p>A monitor <code>MonitorRef</code> is automatically created for the duration of
-this call and an error will be returned if the Gun connection process
-terminates.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_await_body_connpid_streamref_timeout_monitorref_8594_ok_body_error_reason">await_body(ConnPid, StreamRef, Timeout, MonitorRef) &#8594; {ok, Body} | {error, Reason}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream to await messages from.
-</p>
-</dd>
-<dt class="hdlist1">
-Timeout = timeout()
-</dt>
-<dd>
-<p>
-How long this function will wait for each message.
-</p>
-</dd>
-<dt class="hdlist1">
-MonitorRef = reference()
-</dt>
-<dd>
-<p>
-Monitor reference for the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Body = binary()
-</dt>
-<dd>
-<p>
-Body for the given stream.
-</p>
-</dd>
-<dt class="hdlist1">
-Reason = any()
-</dt>
-<dd>
-<p>
-Error reason. @todo any?
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Wait for a response body.</p></div>
-<div class="paragraph"><p>This function can be used when a synchronous handling of
-responses is desired. It will only return when it has
-finished fetching the entire response body.</p></div>
-<div class="paragraph"><p>The timeout value is <strong>per message</strong>. The actual function call
-can last much longer for large bodies.</p></div>
-<div class="paragraph"><p>@todo I think we want to distinguish a stream error, a general error,
-@todo a DOWN and a timeout error</p></div>
-<div class="paragraph"><p>@todo guide might be a little incorrect about await/await_body</p></div>
-</div>
-<div class="sect2">
-<h3 id="_flush_connpid_8594_ok">flush(ConnPid) &#8594; ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Flush all messages from the Gun connection process from the mailbox.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_flush_streamref_8594_ok">flush(StreamRef) &#8594; ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Stream identifier.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Flush all messages related to the given stream.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_cancel_connpid_streamref_8594_ok">cancel(ConnPid, StreamRef) &#8594; ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-StreamRef = reference()
-</dt>
-<dd>
-<p>
-Identifier of the stream to cancel.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Cancel the given stream.</p></div>
-<div class="paragraph"><p>HTTP/1.1 streams can&#8217;t be cancelled. Gun will simply silence
-the stream and stop relaying messages.</p></div>
-<div class="paragraph"><p>@todo Depending on the length
-@todo of a response Gun may also attempt to reconnect rather than
-@todo receive the entire response body.</p></div>
-<div class="paragraph"><p>HTTP/2 streams can however be cancelled at any time.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_ws_upgrade_connpid_path_8594_ws_upgrade_connpid_path">ws_upgrade(ConnPid, Path) &#8594; ws_upgrade(ConnPid, Path, [], #{})</h3>
-<div class="paragraph"><p>Alias of <code>gun:ws_upgrade/3</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_ws_upgrade_connpid_path_headers_8594_ok">ws_upgrade(ConnPid, Path, Headers) &#8594; ok</h3>
-<div class="paragraph"><p>Similar to <code>gun:ws_upgrade/4</code>, except <code>WsOpts</code> is taken from
-the options given in the <code>gun:open/{2,3}</code> call when opening
-the connection.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_ws_upgrade_connpid_path_headers_wsopts_8594_ok">ws_upgrade(ConnPid, Path, Headers, WsOpts) &#8594; ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Path = iodata()
-</dt>
-<dd>
-<p>
-Path to the resource.
-</p>
-</dd>
-<dt class="hdlist1">
-Headers = [{binary(), iodata()}]
-</dt>
-<dd>
-<p>
-Additional request headers.
-</p>
-</dd>
-<dt class="hdlist1">
-WsOpts = map()
-</dt>
-<dd>
-<p>
-Options for the Websocket connection.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Request the connection to be upgraded to the Websocket protocol.</p></div>
-<div class="paragraph"><p>This function can only be used when the current protocol is <code>http</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_ws_send_connpid_frames_8594_ok">ws_send(ConnPid, Frames) &#8594; ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-ConnPid = pid()
-</dt>
-<dd>
-<p>
-The pid of the Gun connection process.
-</p>
-</dd>
-<dt class="hdlist1">
-Frames = @todo
-</dt>
-<dd>
-<p>
-@todo
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Send one or more Websocket frames.</p></div>
-<div class="paragraph"><p>This function can only be used following a successful <code>ws_upgrade</code> call.</p></div>
-</div>
-</div>
-</div>
+<div class="sect1">
+<h2 id="_name">Name</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>gun - asynchronous HTTP client</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_description">Description</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The <code>gun</code> module provides an asynchronous interface for
+connecting and communicating with Web servers over HTTP,
+HTTP/2 or Websocket.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_types">Types</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_opts_map">opts() = map()</h3>
+<div class="paragraph"><p>Configuration for the connection.</p></div>
+<div class="paragraph"><p>The following keys are defined:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+connect_timeout &#8658; timeout()
+</dt>
+<dd>
+<p>
+ Connection timeout. Defaults to <code>infinity</code>.
+</p>
+</dd>
+<dt class="hdlist1">
+http_opts &#8658; http_opts()
+</dt>
+<dd>
+<p>
+ Options specific to the HTTP protocol. See below.
+</p>
+</dd>
+<dt class="hdlist1">
+http2_opts &#8658; http2_opts()
+</dt>
+<dd>
+<p>
+ Options specific to the HTTP/2 protocol. See below.
+</p>
+</dd>
+<dt class="hdlist1">
+protocols &#8658; [http | http2]
+</dt>
+<dd>
+<p>
+ Ordered list of preferred protocols. When the transport is tcp,
+ this list must contain exactly one protocol. When the transport
+ is ssl, this list must contain at least one protocol and will be
+ used using the ALPN protocol negotiation method. When the server
+ does not support ALPN then http will always be used. Defaults to
+ [http] when the transport is tcp, and [http2, http] when the
+ transport is ssl.
+</p>
+</dd>
+<dt class="hdlist1">
+retry &#8658; non_neg_integer()
+</dt>
+<dd>
+<p>
+ Number of times Gun will try to reconnect on failure before giving up.
+ Defaults to 5.
+</p>
+</dd>
+<dt class="hdlist1">
+retry_timeout &#8658; pos_integer()
+</dt>
+<dd>
+<p>
+ Time between retries in milliseconds. Defaults to 5000.
+</p>
+</dd>
+<dt class="hdlist1">
+trace &#8658; boolean()
+</dt>
+<dd>
+<p>
+ Whether to enable <code>dbg</code> tracing of the connection process. Should
+ only be used during debugging. Defaults to false.
+</p>
+</dd>
+<dt class="hdlist1">
+transport &#8658; tcp | ssl
+</dt>
+<dd>
+<p>
+ Whether to use SSL or plain TCP. The default varies depending on the
+ port used. Port 443 defaults to ssl. All other ports default to tcp.
+</p>
+</dd>
+<dt class="hdlist1">
+transport_opts &#8658; proplists:proplist()
+</dt>
+<dd>
+<p>
+ Transport options. They are TCP options or SSL options depending on
+ the selected transport.
+</p>
+</dd>
+<dt class="hdlist1">
+ws_opts &#8658; ws_opts()
+</dt>
+<dd>
+<p>
+ Options specific to the Websocket protocol. See below.
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_http_opts_map">http_opts() = map()</h3>
+<div class="paragraph"><p>Configuration for the HTTP protocol.</p></div>
+<div class="paragraph"><p>The following keys are defined:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+keepalive &#8658; timeout()
+</dt>
+<dd>
+<p>
+ Time between pings in milliseconds. Since the HTTP protocol has
+ no standardized way to ping the server, Gun will simply send an
+ empty line when the connection is idle. Gun only makes a best
+ effort here as servers usually have configurable limits to drop
+ idle connections. Use <code>infinity</code> to disable. Defaults to 5000.
+</p>
+</dd>
+<dt class="hdlist1">
+transform_header_name &#8658; funLowercaseName :: binary( &#8594; TransformedName :: binary()) | undefined
+</dt>
+<dd>
+<p>
+ A function that will be applied to all header names before they
+ are sent to the server. Gun assumes that all header names are in
+ lower case. This function is useful if you, for example, need to
+ re-case header names in the event that the server incorrectly
+ considers header name case to be significant.
+</p>
+</dd>
+<dt class="hdlist1">
+version &#8658; <em>HTTP/1.1</em> | <em>HTTP/1.0</em>
+</dt>
+<dd>
+<p>
+ HTTP version to use. Defaults to <em>HTTP/1.1</em>.
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_http2_opts_map">http2_opts() = map()</h3>
+<div class="paragraph"><p>Configuration for the HTTP/2 protocol.</p></div>
+<div class="paragraph"><p>The following keys are defined:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+keepalive &#8658; pos_integer()
+</dt>
+<dd>
+<p>
+ Time between pings in milliseconds. Defaults to 5000.
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_req_opts_map">req_opts() = map()</h3>
+<div class="paragraph"><p>Configuration for a particular request.</p></div>
+<div class="paragraph"><p>The following keys are defined:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+reply_to &#8658; pid()
+</dt>
+<dd>
+<p>
+ The pid of a process that is responsible for the response handling.
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_ws_opts_map">ws_opts() = map()</h3>
+<div class="paragraph"><p>Configuration for the Websocket protocol.</p></div>
+<div class="paragraph"><p>The following keys are defined:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+compress &#8658; boolean()
+</dt>
+<dd>
+<p>
+ Whether to enable permessage-deflate compression. This does
+ not guarantee that compression will be used as it is the
+ server that ultimately decides. Defaults to false.
+</p>
+</dd>
+</dl></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_messages">Messages</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Calling functions from this module may result in the following
+messages being sent.</p></div>
+<div class="sect2">
+<h3 id="_gun_up_connpid_protocol">{gun_up, ConnPid, Protocol}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Protocol = http | http2
+</dt>
+<dd>
+<p>
+The protocol selected for this connection.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>The connection is up.</p></div>
+<div class="paragraph"><p>This message informs the owner process that the connection or
+reconnection completed.</p></div>
+<div class="paragraph"><p>The protocol selected during the connection is sent in this
+message. It can be used to determine the capabilities of the
+server.</p></div>
+<div class="paragraph"><p>Gun will now start processing the messages it received while
+waiting for the connection to be up. If this is a reconnection,
+then this may not be desirable for all requests. Those requests
+should be cancelled when the connection goes down, and any
+subsequent messages ignored.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_gun_down_connpid_protocol_reason_killedstreams_unprocessedstreams">{gun_down, ConnPid, Protocol, Reason, KilledStreams, UnprocessedStreams}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Protocol = http | http2 | ws
+</dt>
+<dd>
+<p>
+The protocol in use when the connection was lost.
+</p>
+</dd>
+<dt class="hdlist1">
+Reason = normal | closed | {error, atom()}
+</dt>
+<dd>
+<p>
+The reason for the loss of the connection.
+</p>
+</dd>
+<dt class="hdlist1">
+KilledStreams = [reference()]
+</dt>
+<dd>
+<p>
+List of streams that have been brutally terminated.
+</p>
+</dd>
+<dt class="hdlist1">
+UnprocessedStreams = [reference()]
+</dt>
+<dd>
+<p>
+List of streams that have not been processed by the server.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>The connection is down.</p></div>
+<div class="paragraph"><p>This message informs the owner process that the connection is
+currently down. Gun will automatically attempt to reconnect
+depending on the <code>retry</code> and <code>retry_timeout</code> options.</p></div>
+<div class="paragraph"><p>The reason of the termination is there for debugging purposes
+only. You should not rely on this value to know what streams
+were processed or completed.</p></div>
+<div class="paragraph"><p>The <em>killed streams</em> are the active streams that did not complete
+before the closing of the connection. Whether they can be retried
+safely depends on the protocol used and the idempotence property
+of the requests.</p></div>
+<div class="paragraph"><p>The <em>unprocessed streams</em> are streams that the server did not
+start processing yet. They may be retried safely depending on
+what streams were killed before.</p></div>
+<div class="paragraph"><p>When the connection goes back up, Gun will not attempt to retry
+requests. It will also not upgrade to Websocket automatically
+if that was the protocol in use when the connection was lost.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_gun_push_connpid_streamref_newstreamref_uri_headers">{gun_push, ConnPid, StreamRef, NewStreamRef, URI, Headers}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream initiated by the owner process.
+</p>
+</dd>
+<dt class="hdlist1">
+NewStreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream being pushed.
+</p>
+</dd>
+<dt class="hdlist1">
+URI = binary()
+</dt>
+<dd>
+<p>
+URI of the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), binary()}]
+</dt>
+<dd>
+<p>
+Headers @todo
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>A resource pushed alongside an HTTP response.</p></div>
+<div class="paragraph"><p>This message can only be sent when the protocol is HTTP/2.</p></div>
+<div class="paragraph"><p>@todo I fear we also need the scheme; resource is identified by URI
+@todo Perhaps we really should send the URI entirely, because cache
+@todo relies on URI to work and this feature is for caching&#8230;
+@todo Not sure why Method is there, spec says it is only for GET</p></div>
+</div>
+<div class="sect2">
+<h3 id="_gun_response_connpid_streamref_isfin_status_headers">{gun_response, ConnPid, StreamRef, IsFin, Status, Headers}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream initiated by the owner process.
+</p>
+</dd>
+<dt class="hdlist1">
+IsFin = fin | nofin
+</dt>
+<dd>
+<p>
+Whether this message terminates the response.
+</p>
+</dd>
+<dt class="hdlist1">
+Status = binary()
+</dt>
+<dd>
+<p>
+Status line for the response.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), binary()}]
+</dt>
+<dd>
+<p>
+Headers sent with the response.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>A response to an HTTP request.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_gun_data_connpid_streamref_isfin_data">{gun_data, ConnPid, StreamRef, IsFin, Data}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream this data belongs to.
+</p>
+</dd>
+<dt class="hdlist1">
+IsFin = fin | nofin
+</dt>
+<dd>
+<p>
+Whether this message terminates the response.
+</p>
+</dd>
+<dt class="hdlist1">
+Data = binary()
+</dt>
+<dd>
+<p>
+Data from the stream.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Data associated with a stream.</p></div>
+<div class="paragraph"><p>The stream in question can be either one initiated by the owner
+process or a stream initiated by the server through the push
+mechanism. In any case a <code>gun_response</code> or a <code>gun_push</code> message
+will be sent before any <code>gun_data</code> message.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_gun_error_connpid_streamref_reason">{gun_error, ConnPid, StreamRef, Reason}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream this error relates to.
+</p>
+</dd>
+<dt class="hdlist1">
+Reason = any()
+</dt>
+<dd>
+<p>
+Error reason.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Stream-specific error.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_gun_error_connpid_reason">{gun_error, ConnPid, Reason}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Reason = any()
+</dt>
+<dd>
+<p>
+Error reason.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>General error.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_gun_ws_upgrade_connpid_ok_headers">{gun_ws_upgrade, ConnPid, ok, Headers}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), binary()}]
+</dt>
+<dd>
+<p>
+Headers sent with the response.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Successful upgrade to the Websocket protocol.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_gun_ws_connpid_frame">{gun_ws, ConnPid, Frame}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Frame = @todo
+</dt>
+<dd>
+<p>
+Frame.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Websocket frame.</p></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_exports">Exports</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_open_host_port_8594_open_host_port">open(Host, Port) &#8594; open(Host, Port, [])</h3>
+<div class="paragraph"><p>Alias of <code>gun:open/3</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_open_host_port_opts_8594_ok_connpid_error_reason">open(Host, Port, Opts) &#8594; {ok, ConnPid} | {error, Reason}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+Host = inet:hostname()
+</dt>
+<dd>
+<p>
+Host to connect to.
+</p>
+</dd>
+<dt class="hdlist1">
+Port = inet:port_number()
+</dt>
+<dd>
+<p>
+Port to connect to.
+</p>
+</dd>
+<dt class="hdlist1">
+Opts = opts()
+</dt>
+<dd>
+<p>
+Options for this connection.
+</p>
+</dd>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Reason = any()
+</dt>
+<dd>
+<p>
+Error reason. @todo really any?
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Open a connection to the given host and port.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_close_connpid_8594_ok">close(ConnPid) &#8594; ok</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Brutally close the connection.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_shutdown_connpid_8594_ok">shutdown(ConnPid) &#8594; ok</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Gracefully close the connection.</p></div>
+<div class="paragraph"><p>A monitor can be used to be notified when the connection is
+effectively closed.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_delete_connpid_path_8594_delete_connpid_path">delete(ConnPid, Path) &#8594; delete(ConnPid, Path, [], #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:delete/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_delete_connpid_path_headers_8594_delete_connpid_path_headers">delete(ConnPid, Path, Headers) &#8594; delete(ConnPid, Path, Headers, #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:delete/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_delete_connpid_path_headers_reqopts_8594_streamref">delete(ConnPid, Path, Headers, ReqOpts) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+ReqOpts = req_opts()
+</dt>
+<dd>
+<p>
+Request options.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Delete a resource.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_get_connpid_path_8594_get_connpid_path">get(ConnPid, Path) &#8594; get(ConnPid, Path, [], #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:get/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_get_connpid_path_headers_8594_get_connpid_path_headers">get(ConnPid, Path, Headers) &#8594; get(ConnPid, Path, Headers, #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:get/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_get_connpid_path_headers_reqopts_8594_streamref">get(ConnPid, Path, Headers, ReqOpts) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+ReqOpts = req_opts()
+</dt>
+<dd>
+<p>
+Request options.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Get a resource.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_head_connpid_path_8594_head_connpid_path">head(ConnPid, Path) &#8594; head(ConnPid, Path, [], #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:head/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_head_connpid_path_headers_8594_head_connpid_path_headers">head(ConnPid, Path, Headers) &#8594; head(ConnPid, Path, Headers, #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:head/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_head_connpid_path_headers_reqopts_8594_streamref">head(ConnPid, Path, Headers, ReqOpts) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+ReqOpts = req_opts()
+</dt>
+<dd>
+<p>
+Request options.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Get headers of a resource.</p></div>
+<div class="paragraph"><p>This function performs the same operation as <code>get/{2,3}</code> except
+the server will not send the resource representation, only the
+response&#8217;s status line and headers.</p></div>
+<div class="paragraph"><p>While servers should send the same headers they would if the
+request was a GET, like <code>content-length</code>, it is not always
+the case and differences may exist.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_options_connpid_path_8594_options_connpid_path">options(ConnPid, Path) &#8594; options(ConnPid, Path, [], #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:options/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_options_connpid_path_headers_8594_options_connpid_path_headers">options(ConnPid, Path, Headers) &#8594; options(ConnPid, Path, Headers, #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:options/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_options_connpid_path_headers_reqopts_8594_streamref">options(ConnPid, Path, Headers, ReqOpts) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+ReqOpts = req_opts()
+</dt>
+<dd>
+<p>
+Request options.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Obtain information about the capabilities of the server or of a resource.</p></div>
+<div class="paragraph"><p>The special path <code>"*"</code> can be used to obtain information about
+the server as a whole. Any other path will return information
+about the resource only.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_patch_connpid_path_headers_8594_streamref">patch(ConnPid, Path, Headers) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Request that a set of changes be applied to the resource.</p></div>
+<div class="paragraph"><p>This function expects either <code>content-length</code> or <code>content-type</code>
+to be set to know a body is going to be sent afterwards.
+Gun will assume the request has no body otherwise. It is
+highly recommended to set both when possible.</p></div>
+<div class="paragraph"><p>The body sent in this request should be a patch document
+with instructions on how to update the resource.</p></div>
+<div class="paragraph"><p>You can use the <code>gun:data/4</code> function to send the body, if any.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_patch_connpid_path_headers_body_8594_patch_connpid_path_headers_body">patch(ConnPid, Path, Headers, Body) &#8594; patch(ConnPid, Path, Headers, Body, #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:patch/5</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_patch_connpid_path_headers_body_reqopts_8594_streamref">patch(ConnPid, Path, Headers, Body, ReqOpts) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+Body = iodata()
+</dt>
+<dd>
+<p>
+Body of the request.
+</p>
+</dd>
+<dt class="hdlist1">
+ReqOpts = req_opts()
+</dt>
+<dd>
+<p>
+Request options.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Request that a set of changes be applied to the resource.</p></div>
+<div class="paragraph"><p>It is highly recommended to set the <code>content-type</code> header
+to inform the server what media type the body contains.
+Gun will automatically set the <code>content-length</code> header.</p></div>
+<div class="paragraph"><p>The body sent in this request should be a patch document
+with instructions on how to update the resource.</p></div>
+<div class="paragraph"><p>The complete request is sent when calling this function.
+It is not possible to stream more of the body after
+calling it.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_post_connpid_path_headers_8594_streamref">post(ConnPid, Path, Headers) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Process the enclosed representation according to the resource&#8217;s own semantics.</p></div>
+<div class="paragraph"><p>This function expects either <code>content-length</code> or <code>content-type</code>
+to be set to know a body is going to be sent afterwards.
+Gun will assume the request has no body otherwise. It is
+highly recommended to set both when possible.</p></div>
+<div class="paragraph"><p>The body sent in this request will be processed
+according to the resource&#8217;s own semantics. A new
+resource may be created as a result, and may be
+located at a different URI.</p></div>
+<div class="paragraph"><p>You can use the <code>gun:data/4</code> function to send the body, if any.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_post_connpid_path_headers_body_8594_post_connpid_path_headers_body">post(ConnPid, Path, Headers, Body) &#8594; post(ConnPid, Path, Headers, Body, #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:post/5</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_post_connpid_path_headers_body_reqopts_8594_streamref">post(ConnPid, Path, Headers, Body, ReqOpts) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+Body = iodata()
+</dt>
+<dd>
+<p>
+Body of the request.
+</p>
+</dd>
+<dt class="hdlist1">
+ReqOpts = req_opts()
+</dt>
+<dd>
+<p>
+Request options.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Process the enclosed representation according to the resource&#8217;s own semantics.</p></div>
+<div class="paragraph"><p>It is highly recommended to set the <code>content-type</code> header
+to inform the server what media type the body contains.
+Gun will automatically set the <code>content-length</code> header.</p></div>
+<div class="paragraph"><p>The body sent in this request will be processed
+according to the resource&#8217;s own semantics. A new
+resource may be created as a result, and may be
+located at a different URI.</p></div>
+<div class="paragraph"><p>The complete request is sent when calling this function.
+It is not possible to stream more of the body after
+calling it.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_put_connpid_path_headers_8594_streamref">put(ConnPid, Path, Headers) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Create or replace a resource.</p></div>
+<div class="paragraph"><p>The body of the request is the entire representation of the resource.</p></div>
+<div class="paragraph"><p>This function expects either <code>content-length</code> or <code>content-type</code>
+to be set to know a body is going to be sent afterwards.
+Gun will assume the request has no body otherwise. It is
+highly recommended to set both when possible.</p></div>
+<div class="paragraph"><p>You can use the <code>gun:data/4</code> function to send the body, if any.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_put_connpid_path_headers_body_8594_put_connpid_path_headers_body">put(ConnPid, Path, Headers, Body) &#8594; put(ConnPid, Path, Headers, Body, #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:put/5</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_put_connpid_path_headers_body_reqopts_8594_streamref">put(ConnPid, Path, Headers, Body, ReqOpts) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+Body = iodata()
+</dt>
+<dd>
+<p>
+Body of the request.
+</p>
+</dd>
+<dt class="hdlist1">
+ReqOpts = req_opts()
+</dt>
+<dd>
+<p>
+Request options.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Create or replace a resource.</p></div>
+<div class="paragraph"><p>The body of the request is the entire representation of the resource.</p></div>
+<div class="paragraph"><p>It is highly recommended to set the <code>content-type</code> header
+to inform the server what media type the body contains.
+Gun will automatically set the <code>content-length</code> header.</p></div>
+<div class="paragraph"><p>The complete request is sent when calling this function.
+It is not possible to stream more of the body after
+calling it.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_request_connpid_method_path_headers_8594_streamref">request(ConnPid, Method, Path, Headers) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Method = iodata()
+</dt>
+<dd>
+<p>
+Request method.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path of the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Perform the given request.</p></div>
+<div class="paragraph"><p>This is a general purpose function that should only be used
+when existing method-specific functions don&#8217;t apply.</p></div>
+<div class="paragraph"><p>This function expects either <code>content-length</code> or <code>content-type</code>
+to be set to know a body is going to be sent afterwards.
+Gun will assume the request has no body otherwise. It is
+highly recommended to set both when possible.</p></div>
+<div class="paragraph"><p>You can use the <code>gun:data/4</code> function to send the body, if any.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_request_connpid_method_path_headers_body_8594_request_connpid_method_path_headers_body">request(ConnPid, Method, Path, Headers, Body) &#8594; request(ConnPid, Method, Path, Headers, Body, #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:request/6</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_request_connpid_method_path_headers_body_reqopts_8594_streamref">request(ConnPid, Method, Path, Headers, Body, ReqOpts) &#8594; StreamRef</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Method = iodata()
+</dt>
+<dd>
+<p>
+Request method.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path of the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+Body = iodata()
+</dt>
+<dd>
+<p>
+Body of the request.
+</p>
+</dd>
+<dt class="hdlist1">
+ReqOpts = req_opts()
+</dt>
+<dd>
+<p>
+Request options.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream for this request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Perform the given request.</p></div>
+<div class="paragraph"><p>This is a general purpose function that should only be used
+when existing method-specific functions don&#8217;t apply.</p></div>
+<div class="paragraph"><p>It is highly recommended to set the <code>content-type</code> header
+to inform the server what media type the body contains.
+Gun will automatically set the <code>content-length</code> header.</p></div>
+<div class="paragraph"><p>The complete request is sent when calling this function.
+It is not possible to stream more of the body after
+calling it.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_data_connpid_streamref_isfin_data_8594_ok">data(ConnPid, StreamRef, IsFin, Data) &#8594; ok</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream this data belongs to.
+</p>
+</dd>
+<dt class="hdlist1">
+IsFin = fin | nofin
+</dt>
+<dd>
+<p>
+Whether this message terminates the request.
+</p>
+</dd>
+<dt class="hdlist1">
+Data = iodata()
+</dt>
+<dd>
+<p>
+Data to be sent with the request.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Stream the body of a request.</p></div>
+<div class="paragraph"><p>@todo empty chunks</p></div>
+<div class="paragraph"><p>This function can only be used if the request identified by
+<code>StreamRef</code> came with headers indicating the presence of a
+body and that body not being given when creating the request.</p></div>
+<div class="paragraph"><p>All calls to this function must use <code>nofin</code> except for the
+last which must use <code>fin</code> to indicate the end of the request
+body.</p></div>
+<div class="paragraph"><p>Empty data is allowed regardless of the value of <code>IsFin</code>.
+Gun will not send empty data chunks unless required to
+indicate the request body is finished, however.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_await_connpid_streamref_8594_await_connpid_streamref_5000_monitorref">await(ConnPid, StreamRef) &#8594; await(ConnPid, StreamRef, 5000, MonitorRef)</h3>
+<div class="paragraph"><p>Alias of <code>gun:await/4</code>.</p></div>
+<div class="paragraph"><p>A monitor <code>MonitorRef</code> is automatically created for the duration of
+this call and an error will be returned if the Gun connection process
+terminates.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_await_connpid_streamref_monitorref_8594_await_connpid_streamref_5000_monitorref">await(ConnPid, StreamRef, MonitorRef) &#8594; await(ConnPid, StreamRef, 5000, MonitorRef)</h3>
+<div class="paragraph"><p>Alias of <code>gun:await/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_await_connpid_streamref_timeout_8594_await_connpid_streamref_timeout_monitorref">await(ConnPid, StreamRef, Timeout) &#8594; await(ConnPid, StreamRef, Timeout, MonitorRef)</h3>
+<div class="paragraph"><p>Alias of <code>gun:await/4</code>.</p></div>
+<div class="paragraph"><p>A monitor <code>MonitorRef</code> is automatically created for the duration of
+this call and an error will be returned if the Gun connection process
+terminates.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_await_connpid_streamref_timeout_monitorref_8594_tuple_8201_8212_8201_see_below">await(ConnPid, StreamRef, Timeout, MonitorRef) &#8594; tuple()&#8201;&#8212;&#8201;see below</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream to await messages from.
+</p>
+</dd>
+<dt class="hdlist1">
+Timeout = timeout()
+</dt>
+<dd>
+<p>
+How long this function will wait for messages.
+</p>
+</dd>
+<dt class="hdlist1">
+MonitorRef = reference()
+</dt>
+<dd>
+<p>
+Monitor reference for the Gun connection process.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Wait for a response message.</p></div>
+<div class="paragraph"><p>This function can be used when a synchronous handling of
+responses is desired. It will only return when a message
+for the given stream is received, on error or on timeout.</p></div>
+<div class="paragraph"><p>The return values are described in the next few subsections.</p></div>
+<div class="sect3">
+<h4 id="_response_isfin_status_headers">{response, IsFin, Status, Headers}</h4>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+IsFin = fin | nofin
+</dt>
+<dd>
+<p>
+Whether this message terminates the response.
+</p>
+</dd>
+<dt class="hdlist1">
+Status = binary()
+</dt>
+<dd>
+<p>
+Status line for the response.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), binary()}]
+</dt>
+<dd>
+<p>
+Headers sent with the response.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Equivalent of a <code>gun_response</code> message.</p></div>
+</div>
+<div class="sect3">
+<h4 id="_data_isfin_data">{data, IsFin, Data}</h4>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+IsFin = fin | nofin
+</dt>
+<dd>
+<p>
+Whether this message terminates the response.
+</p>
+</dd>
+<dt class="hdlist1">
+Data = binary()
+</dt>
+<dd>
+<p>
+Data from the stream.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Equivalent of a <code>gun_data</code> message.</p></div>
+</div>
+<div class="sect3">
+<h4 id="_push_newstreamref_uri_headers">{push, NewStreamRef, URI, Headers}</h4>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+NewStreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream being pushed.
+</p>
+</dd>
+<dt class="hdlist1">
+URI = binary()
+</dt>
+<dd>
+<p>
+URI of the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), binary()}]
+</dt>
+<dd>
+<p>
+Headers @todo
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Equivalent of a <code>gun_push</code> message.</p></div>
+<div class="paragraph"><p>@todo Same changes as gun_push</p></div>
+</div>
+<div class="sect3">
+<h4 id="_error_reason">{error, Reason}</h4>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+Reason = any()
+</dt>
+<dd>
+<p>
+Error reason. @todo any?
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Equivalent of a <code>gun_error</code> message.</p></div>
+<div class="paragraph"><p>@todo I think we want to distinguish a stream error, a general error,
+@todo a DOWN and a timeout error</p></div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_await_body_connpid_streamref_8594_await_body_connpid_streamref_5000_monitorref">await_body(ConnPid, StreamRef) &#8594; await_body(ConnPid, StreamRef, 5000, MonitorRef)</h3>
+<div class="paragraph"><p>Alias of <code>gun:await_body/4</code>.</p></div>
+<div class="paragraph"><p>A monitor <code>MonitorRef</code> is automatically created for the duration of
+this call and an error will be returned if the Gun connection process
+terminates.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_await_body_connpid_streamref_monitorref_8594_await_body_connpid_streamref_5000_monitorref">await_body(ConnPid, StreamRef, MonitorRef) &#8594; await_body(ConnPid, StreamRef, 5000, MonitorRef)</h3>
+<div class="paragraph"><p>Alias of <code>gun:await_body/4</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_await_body_connpid_streamref_timeout_8594_await_body_connpid_streamref_timeout_monitorref">await_body(ConnPid, StreamRef, Timeout) &#8594; await_body(ConnPid, StreamRef, Timeout, MonitorRef)</h3>
+<div class="paragraph"><p>Alias of <code>gun:await_body/4</code>.</p></div>
+<div class="paragraph"><p>A monitor <code>MonitorRef</code> is automatically created for the duration of
+this call and an error will be returned if the Gun connection process
+terminates.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_await_body_connpid_streamref_timeout_monitorref_8594_ok_body_error_reason">await_body(ConnPid, StreamRef, Timeout, MonitorRef) &#8594; {ok, Body} | {error, Reason}</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream to await messages from.
+</p>
+</dd>
+<dt class="hdlist1">
+Timeout = timeout()
+</dt>
+<dd>
+<p>
+How long this function will wait for each message.
+</p>
+</dd>
+<dt class="hdlist1">
+MonitorRef = reference()
+</dt>
+<dd>
+<p>
+Monitor reference for the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Body = binary()
+</dt>
+<dd>
+<p>
+Body for the given stream.
+</p>
+</dd>
+<dt class="hdlist1">
+Reason = any()
+</dt>
+<dd>
+<p>
+Error reason. @todo any?
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Wait for a response body.</p></div>
+<div class="paragraph"><p>This function can be used when a synchronous handling of
+responses is desired. It will only return when it has
+finished fetching the entire response body.</p></div>
+<div class="paragraph"><p>The timeout value is <strong>per message</strong>. The actual function call
+can last much longer for large bodies.</p></div>
+<div class="paragraph"><p>@todo I think we want to distinguish a stream error, a general error,
+@todo a DOWN and a timeout error</p></div>
+<div class="paragraph"><p>@todo guide might be a little incorrect about await/await_body</p></div>
+</div>
+<div class="sect2">
+<h3 id="_flush_connpid_8594_ok">flush(ConnPid) &#8594; ok</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Flush all messages from the Gun connection process from the mailbox.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_flush_streamref_8594_ok">flush(StreamRef) &#8594; ok</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Stream identifier.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Flush all messages related to the given stream.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_cancel_connpid_streamref_8594_ok">cancel(ConnPid, StreamRef) &#8594; ok</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+StreamRef = reference()
+</dt>
+<dd>
+<p>
+Identifier of the stream to cancel.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Cancel the given stream.</p></div>
+<div class="paragraph"><p>HTTP/1.1 streams can&#8217;t be cancelled. Gun will simply silence
+the stream and stop relaying messages.</p></div>
+<div class="paragraph"><p>@todo Depending on the length
+@todo of a response Gun may also attempt to reconnect rather than
+@todo receive the entire response body.</p></div>
+<div class="paragraph"><p>HTTP/2 streams can however be cancelled at any time.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_ws_upgrade_connpid_path_8594_ws_upgrade_connpid_path">ws_upgrade(ConnPid, Path) &#8594; ws_upgrade(ConnPid, Path, [], #{})</h3>
+<div class="paragraph"><p>Alias of <code>gun:ws_upgrade/3</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_ws_upgrade_connpid_path_headers_8594_ok">ws_upgrade(ConnPid, Path, Headers) &#8594; ok</h3>
+<div class="paragraph"><p>Similar to <code>gun:ws_upgrade/4</code>, except <code>WsOpts</code> is taken from
+the options given in the <code>gun:open/{2,3}</code> call when opening
+the connection.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_ws_upgrade_connpid_path_headers_wsopts_8594_ok">ws_upgrade(ConnPid, Path, Headers, WsOpts) &#8594; ok</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Path = iodata()
+</dt>
+<dd>
+<p>
+Path to the resource.
+</p>
+</dd>
+<dt class="hdlist1">
+Headers = [{binary(), iodata()}]
+</dt>
+<dd>
+<p>
+Additional request headers.
+</p>
+</dd>
+<dt class="hdlist1">
+WsOpts = map()
+</dt>
+<dd>
+<p>
+Options for the Websocket connection.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Request the connection to be upgraded to the Websocket protocol.</p></div>
+<div class="paragraph"><p>This function can only be used when the current protocol is <code>http</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_ws_send_connpid_frames_8594_ok">ws_send(ConnPid, Frames) &#8594; ok</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+ConnPid = pid()
+</dt>
+<dd>
+<p>
+The pid of the Gun connection process.
+</p>
+</dd>
+<dt class="hdlist1">
+Frames = @todo
+</dt>
+<dd>
+<p>
+@todo
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Send one or more Websocket frames.</p></div>
+<div class="paragraph"><p>This function can only be used following a successful <code>ws_upgrade</code> call.</p></div>
+</div>
+</div>
+</div>
diff --git a/docs/en/gun/1.0/manual/gun_app/index.html b/docs/en/gun/1.0/manual/gun_app/index.html
index be525d51..5690ca2b 100644
--- a/docs/en/gun/1.0/manual/gun_app/index.html
+++ b/docs/en/gun/1.0/manual/gun_app/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: gun(7)</title>
@@ -67,34 +67,34 @@
<h1 class="lined-header"><span>gun(7)</span></h1>
-<div class="sect1">
-<h2 id="_name">Name</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>gun - Erlang HTTP client with support for HTTP/1.1, HTTP/2 and Websocket.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_dependencies">Dependencies</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>The <code>gun</code> application uses the Erlang applications <code>ranch</code>
-for abstracting TCP and TLS over a common interface, and
-the <code>ssl</code> application for TLS support, required for HTTPS
-and secure HTTP/2 support. In addition, Gun requires the <code>crypto</code>
-application (a dependency of <code>ssl</code>) for Websocket.</p></div>
-<div class="paragraph"><p>These dependencies must be started for the <code>gun</code>
-application to work. In an embedded environment
-this means that they need to be started with the
-<code>application:start/{1,2}</code> function before the <code>gun</code>
-application is started.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_environment">Environment</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>The <code>gun</code> application does not define any application
-environment configuration parameters.</p></div>
-</div>
-</div>
+<div class="sect1">
+<h2 id="_name">Name</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>gun - Erlang HTTP client with support for HTTP/1.1, HTTP/2 and Websocket.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_dependencies">Dependencies</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The <code>gun</code> application uses the Erlang applications <code>ranch</code>
+for abstracting TCP and TLS over a common interface, and
+the <code>ssl</code> application for TLS support, required for HTTPS
+and secure HTTP/2 support. In addition, Gun requires the <code>crypto</code>
+application (a dependency of <code>ssl</code>) for Websocket.</p></div>
+<div class="paragraph"><p>These dependencies must be started for the <code>gun</code>
+application to work. In an embedded environment
+this means that they need to be started with the
+<code>application:start/{1,2}</code> function before the <code>gun</code>
+application is started.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_environment">Environment</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The <code>gun</code> application does not define any application
+environment configuration parameters.</p></div>
+</div>
+</div>
diff --git a/docs/en/gun/1.0/manual/index.html b/docs/en/gun/1.0/manual/index.html
index 411e92f0..c3851885 100644
--- a/docs/en/gun/1.0/manual/index.html
+++ b/docs/en/gun/1.0/manual/index.html
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
- <meta name="generator" content="Hugo 0.17" />
+ <meta name="generator" content="Hugo 0.26" />
<title>Nine Nines: Gun Function Reference</title>
@@ -67,18 +67,18 @@
<h1 class="lined-header"><span>Gun Function Reference</span></h1>
-<div class="ulist"><ul>
-<li>
-<p>
-<a href="gun_app">gun(7)</a>
-</p>
-</li>
-<li>
-<p>
-<a href="gun">gun(3)</a>
-</p>
-</li>
-</ul></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="gun_app">gun(7)</a>
+</p>
+</li>
+<li>
+<p>
+<a href="gun">gun(3)</a>
+</p>
+</li>
+</ul></div>
diff --git a/docs/en/gun/index.html b/docs/en/gun/index.html
index d87c4243..0194031a 100644
--- a/docs/en/gun/index.html
+++ b/docs/en/gun/index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><title>https://ninenines.eu/docs/</title><link rel="canonical" href="https://ninenines.eu/docs/"/><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="refresh" content="0; url=https://ninenines.eu/docs/" /></head></html> \ No newline at end of file
+<!DOCTYPE html><html><head><title>https://ninenines.eu/docs/</title><link rel="canonical" href="https://ninenines.eu/docs/"/><meta name="robots" content="noindex"><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="refresh" content="0; url=https://ninenines.eu/docs/" /></head></html> \ No newline at end of file