summaryrefslogtreecommitdiffstats
path: root/docs/en/gun/2.1/guide
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2024-03-14 16:23:56 +0100
committerLoïc Hoguin <[email protected]>2024-03-14 16:23:56 +0100
commit5e05fe8e7877ffd6bc473b77b8ca0a12ad26bd67 (patch)
treecdfd7f160ae7cb2943b1e422140c25a2e8f00c4e /docs/en/gun/2.1/guide
parent2368dc53d0c724f1899aeb2874ba1a763e11f0b8 (diff)
downloadninenines.eu-5e05fe8e7877ffd6bc473b77b8ca0a12ad26bd67.tar.gz
ninenines.eu-5e05fe8e7877ffd6bc473b77b8ca0a12ad26bd67.tar.bz2
ninenines.eu-5e05fe8e7877ffd6bc473b77b8ca0a12ad26bd67.zip
Cowboy 2.12, Cowlib 2.13, Gun 2.1
Diffstat (limited to 'docs/en/gun/2.1/guide')
-rw-r--r--docs/en/gun/2.1/guide/connect.asciidoc166
-rw-r--r--docs/en/gun/2.1/guide/connect/index.html278
-rw-r--r--docs/en/gun/2.1/guide/gun.sty8
-rw-r--r--docs/en/gun/2.1/guide/http.asciidoc387
-rw-r--r--docs/en/gun/2.1/guide/http/index.html452
-rw-r--r--docs/en/gun/2.1/guide/index.html188
-rw-r--r--docs/en/gun/2.1/guide/internals_tls_over_tls.asciidoc177
-rw-r--r--docs/en/gun/2.1/guide/internals_tls_over_tls/index.html222
-rw-r--r--docs/en/gun/2.1/guide/introduction.asciidoc49
-rw-r--r--docs/en/gun/2.1/guide/introduction/index.html203
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_1.0.asciidoc21
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_1.0/index.html189
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_1.1.asciidoc28
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_1.1/index.html195
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_1.2.asciidoc39
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_1.2/index.html205
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_1.3.asciidoc329
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_1.3/index.html337
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_2.0.asciidoc25
-rw-r--r--docs/en/gun/2.1/guide/migrating_from_2.0/index.html194
-rw-r--r--docs/en/gun/2.1/guide/protocols.asciidoc120
-rw-r--r--docs/en/gun/2.1/guide/protocols/index.html329
-rw-r--r--docs/en/gun/2.1/guide/start.asciidoc43
-rw-r--r--docs/en/gun/2.1/guide/start/index.html206
-rw-r--r--docs/en/gun/2.1/guide/websocket.asciidoc124
-rw-r--r--docs/en/gun/2.1/guide/websocket/index.html264
26 files changed, 4778 insertions, 0 deletions
diff --git a/docs/en/gun/2.1/guide/connect.asciidoc b/docs/en/gun/2.1/guide/connect.asciidoc
new file mode 100644
index 00000000..08f8db29
--- /dev/null
+++ b/docs/en/gun/2.1/guide/connect.asciidoc
@@ -0,0 +1,166 @@
+[[connect]]
+== Connection
+
+This chapter describes how to open, monitor and close
+a connection using the Gun client.
+
+=== Gun connections
+
+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.
+
+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 _owner_ of the connection, and is
+managed by the supervision tree of the `gun` application.
+
+Any process can communicate with the Gun connection
+by calling functions from the module `gun`. All functions
+perform their respective operations asynchronously. The Gun
+connection will send Erlang messages to the calling process
+whenever needed.
+
+When the remote endpoint closes the connection, Gun attempts
+to reconnect automatically.
+
+=== Opening a new connection
+
+The `gun:open/2,3` function must be used to open a connection.
+
+.Opening a connection to example.org on port 443
+[source,erlang]
+----
+{ok, ConnPid} = gun:open("example.org", 443).
+----
+
+If the port given is 443, Gun will attempt to connect using
+TLS. 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 TLS.
+
+For any other port, Gun will attempt to connect using
+plain TCP and will use the HTTP/1.1 protocol.
+
+The transport and protocol used can be overriden via
+options. The manual documents all available options.
+
+Options can be provided as a third argument, and take the
+form of a map.
+
+.Opening a TLS connection to example.org on port 8443
+[source,erlang]
+----
+{ok, ConnPid} = gun:open("example.org", 8443, #{transport => tls}).
+----
+
+When using TLS you may want to tweak the
+http://erlang.org/doc/man/ssl_app.html#configuration[configuration]
+for the `ssl` application, in particular the `session_lifetime`
+and `session_cache_client_max` to limit the amount of memory
+used for the TLS sessions cache.
+
+=== Waiting for the connection to be established
+
+When Gun successfully connects to the server, it sends a
+`gun_up` message with the protocol that has been selected
+for the connection.
+
+Gun provides the functions `gun:await_up/1,2,3` that wait
+for the `gun_up` 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.
+
+.Synchronous opening of a connection
+[source,erlang]
+----
+{ok, ConnPid} = gun:open("example.org", 443),
+{ok, Protocol} = gun:await_up(ConnPid).
+----
+
+=== Handling connection loss
+
+When the connection is lost, Gun will send a `gun_down`
+message indicating the current protocol, the reason the
+connection was lost and two lists of stream references.
+
+The first list indicates open streams that _may_ have been
+processed by the server. The second list indicates open
+streams that the server did not process.
+
+=== Monitoring the connection process
+
+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.
+
+Gun leaves you the choice as to which one will be used.
+However, if you use the `gun:await/2,3` or `gun:await_body/2,3`
+functions, a monitor may be used for you to avoid getting
+stuck waiting for a message that will never come.
+
+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 `gun:await/3,4` and `gun:await_body/3,4`
+functions both accept a monitor argument if you have one already.
+
+.Monitoring the connection process
+[source,erlang]
+----
+{ok, ConnPid} = gun:open("example.org", 443).
+MRef = monitor(process, ConnPid).
+----
+
+This monitor reference can be kept and used until the connection
+process exits.
+
+.Handling `DOWN` messages
+[source,erlang]
+----
+receive
+ %% Receive Gun messages here...
+ {'DOWN', Mref, process, ConnPid, Reason} ->
+ error_logger:error_msg("Oops!"),
+ exit(Reason)
+end.
+----
+
+What to do when you receive a `DOWN` message is entirely up to you.
+
+=== Closing the connection abruptly
+
+The connection can be stopped abruptly at any time by calling
+the `gun:close/1` function.
+
+.Immediate closing of the connection
+[source,erlang]
+----
+gun:close(ConnPid).
+----
+
+The process is stopped immediately without having a chance to
+perform the protocol's closing handshake, if any.
+
+//=== Closing the connection gracefully
+//
+//The connection can also be stopped gracefully by calling the
+//`gun:shutdown/1` function.
+//
+//.Graceful shutdown of the connection
+//[source,erlang]
+//----
+//gun:shutdown(ConnPid).
+//----
+//
+//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.
+//
+//For example if you performed a GET request just before calling
+//`gun:shutdown/1`, you will still receive the response before
+//Gun closes the connection.
+//
+//If you set a monitor beforehand, you will receive a message
+//when the connection has been closed.
diff --git a/docs/en/gun/2.1/guide/connect/index.html b/docs/en/gun/2.1/guide/connect/index.html
new file mode 100644
index 00000000..d307a4f0
--- /dev/null
+++ b/docs/en/gun/2.1/guide/connect/index.html
@@ -0,0 +1,278 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Connection</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Connection</span></h1>
+
+<p>This chapter describes how to open, monitor and close a connection using the Gun client.</p>
+<h2 id="_gun_connections">Gun connections</h2>
+<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>
+<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>
+<p>Any process can communicate 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 calling process whenever needed.</p>
+<p>When the remote endpoint closes the connection, Gun attempts to reconnect automatically.</p>
+<h2 id="_opening_a_new_connection">Opening a new connection</h2>
+<p>The <code>gun:open/2,3</code> function must be used to open a connection.</p>
+<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.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<font color="#FF6600">ok</font>, <font color="#009900">ConnPid</font>} <font color="#990000">=</font> <b><font color="#000000">gun:open</font></b>(<font color="#FF0000">"example.org"</font>, <font color="#993399">443</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>If the port given is 443, Gun will attempt to connect using TLS. 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 TLS.</p>
+<p>For any other port, Gun will attempt to connect using plain TCP and will use the HTTP/1.1 protocol.</p>
+<p>The transport and protocol used can be overriden via options. The manual documents all available options.</p>
+<p>Options can be provided as a third argument, and take the form of a map.</p>
+<div class="listingblock"><div class="title">Opening a TLS connection to example.org on port 8443</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<font color="#FF6600">ok</font>, <font color="#009900">ConnPid</font>} <font color="#990000">=</font> <b><font color="#000000">gun:open</font></b>(<font color="#FF0000">"example.org"</font>, <font color="#993399">8443</font>, #{<font color="#0000FF">transport</font> <font color="#990000">=&gt;</font> <font color="#FF6600">tls</font>})<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>When using TLS you may want to tweak the <a href="http://erlang.org/doc/man/ssl_app.html#configuration">configuration</a> for the <code>ssl</code> application, in particular the <code>session_lifetime</code> and <code>session_cache_client_max</code> to limit the amount of memory used for the TLS sessions cache.</p>
+<h2 id="_waiting_for_the_connection_to_be_established">Waiting for the connection to be established</h2>
+<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>
+<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 class="listingblock"><div class="title">Synchronous opening of a connection</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<font color="#FF6600">ok</font>, <font color="#009900">ConnPid</font>} <font color="#990000">=</font> <b><font color="#000000">gun:open</font></b>(<font color="#FF0000">"example.org"</font>, <font color="#993399">443</font>),
+{<font color="#FF6600">ok</font>, <font color="#009900">Protocol</font>} <font color="#990000">=</font> <b><font color="#000000">gun:await_up</font></b>(<font color="#009900">ConnPid</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<h2 id="_handling_connection_loss">Handling connection loss</h2>
+<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 lists of stream references.</p>
+<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>
+<h2 id="_monitoring_the_connection_process">Monitoring the connection process</h2>
+<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>
+<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>
+<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 class="listingblock"><div class="title">Monitoring the connection process</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<font color="#FF6600">ok</font>, <font color="#009900">ConnPid</font>} <font color="#990000">=</font> <b><font color="#000000">gun:open</font></b>(<font color="#FF0000">"example.org"</font>, <font color="#993399">443</font>)<font color="#990000">.</font>
+<font color="#009900">MRef</font> <font color="#990000">=</font> <b><font color="#000000">monitor</font></b>(<b><font color="#000080">process</font></b>, <font color="#009900">ConnPid</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>This monitor reference can be kept and used until the connection process exits.</p>
+<div class="listingblock"><div class="title">Handling `DOWN` messages</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#0000FF">receive</font></b>
+ <i><font color="#9A1900">%% Receive Gun messages here...</font></i>
+ {<font color="#FF6600">'DOWN'</font>, <font color="#009900">Mref</font>, <b><font color="#000080">process</font></b>, <font color="#009900">ConnPid</font>, <font color="#009900">Reason</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">error_logger:error_msg</font></b>(<font color="#FF0000">"Oops!"</font>),
+ <b><font color="#000080">exit</font></b>(<font color="#009900">Reason</font>)
+<b><font color="#0000FF">end</font></b><font color="#990000">.</font></tt></pre>
+</div></div>
+<p>What to do when you receive a <code>DOWN</code> message is entirely up to you.</p>
+<h2 id="_closing_the_connection_abruptly">Closing the connection abruptly</h2>
+<p>The connection can be stopped abruptly at any time by calling the <code>gun:close/1</code> function.</p>
+<div class="listingblock"><div class="title">Immediate closing of the connection</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">gun:close</font></b>(<font color="#009900">ConnPid</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>The process is stopped immediately without having a chance to perform the protocol&apos;s closing handshake, if any.</p>
+<!-- === Closing the connection gracefully-->
+<!-- -->
+<!-- The connection can also be stopped gracefully by calling the-->
+<!-- `gun:shutdown/1` function.-->
+<!-- -->
+<!-- .Graceful shutdown of the connection-->
+<!-- [source,erlang]-->
+<!-- ------>
+<!-- gun:shutdown(ConnPid).-->
+<!-- ------>
+<!-- -->
+<!-- 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.-->
+<!-- -->
+<!-- For example if you performed a GET request just before calling-->
+<!-- `gun:shutdown/1`, you will still receive the response before-->
+<!-- Gun closes the connection.-->
+<!-- -->
+<!-- If you set a monitor beforehand, you will receive a message-->
+<!-- when the connection has been closed.-->
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/protocols/">
+ Supported protocols
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/http/">
+ HTTP
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/gun.sty b/docs/en/gun/2.1/guide/gun.sty
new file mode 100644
index 00000000..d5e0d3be
--- /dev/null
+++ b/docs/en/gun/2.1/guide/gun.sty
@@ -0,0 +1,8 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{asciidoc-dblatex}[2012/10/24 AsciiDoc DocBook Style]
+
+%% Just use the original package and pass the options.
+\RequirePackageWithOptions{docbook}
+
+%% Define an alias for make snippets to be compatible with source-highlighter.
+\lstalias{makefile}{make}
diff --git a/docs/en/gun/2.1/guide/http.asciidoc b/docs/en/gun/2.1/guide/http.asciidoc
new file mode 100644
index 00000000..51cb994f
--- /dev/null
+++ b/docs/en/gun/2.1/guide/http.asciidoc
@@ -0,0 +1,387 @@
+[[http]]
+== HTTP
+
+This chapter describes how to use the Gun client for
+communicating with an HTTP/1.1 or HTTP/2 server.
+
+=== Streams
+
+Every time a request is initiated, Gun creates a _stream_.
+A _stream reference_ uniquely identifies a set of request and
+response and must be used to perform additional operations
+with a stream or to identify its messages.
+
+Stream references use the Erlang _reference_ data type and
+are therefore unique.
+
+Streams can be canceled at any time. This will stop any further
+messages from being sent to the calling process. Depending on
+its capabilities, the server will also be instructed to cancel
+the request.
+
+Canceling a stream may result in Gun dropping the connection
+temporarily, to avoid uploading or downloading data that will
+not be used.
+
+.Cancelling a stream
+[source,erlang]
+----
+gun:cancel(ConnPid, StreamRef).
+----
+
+=== Sending requests
+
+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.
+
+The availability of these methods on the server can vary
+depending on the software used but also on a per-resource
+basis.
+
+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.
+
+This section focuses on the act of sending a request. The
+handling of responses will be explained further on.
+
+==== GET and HEAD
+
+Use `gun:get/2,3,4` to request a resource.
+
+.GET "/organizations/ninenines"
+[source,erlang]
+----
+StreamRef = gun:get(ConnPid, "/organizations/ninenines").
+----
+
+.GET "/organizations/ninenines" with custom headers
+[source,erlang]
+----
+StreamRef = gun:get(ConnPid, "/organizations/ninenines", [
+ {<<"accept">>, "application/json"},
+ {<<"user-agent">>, "revolver/1.0"}
+]).
+----
+
+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.
+
+Use `gun:head/2,3,4` if you don't need the response body.
+
+.HEAD "/organizations/ninenines"
+[source,erlang]
+----
+StreamRef = gun:head(ConnPid, "/organizations/ninenines").
+----
+
+.HEAD "/organizations/ninenines" with custom headers
+[source,erlang]
+----
+StreamRef = gun:head(ConnPid, "/organizations/ninenines", [
+ {<<"accept">>, "application/json"},
+ {<<"user-agent">>, "revolver/1.0"}
+]).
+----
+
+It is not possible to send a request body with a GET or HEAD
+request.
+
+==== POST, PUT and PATCH
+
+HTTP defines three methods to create or update a resource.
+
+POST is generally used when the resource identifier (URI) isn't known
+in advance when creating a resource. POST can also be used to
+replace an existing resource, although PUT is more appropriate
+in that situation.
+
+PUT creates or replaces a resource identified by the URI.
+
+PATCH provides instructions on how to modify the resource.
+
+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.
+
+The functions `gun:post/4,5`, `gun:put/4,5` and `gun:patch/4,5`
+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.
+
+In this and the following examples in this section, `gun:post`
+can be replaced by `gun:put` or `gun:patch` for performing
+a PUT or PATCH request, respectively.
+
+.POST "/organizations/ninenines"
+[source,erlang]
+----
+Body = "{\"msg\": \"Hello world!\"}",
+StreamRef = gun:post(ConnPid, "/organizations/ninenines", [
+ {<<"content-type">>, "application/json"}
+], Body).
+----
+
+The functions `gun:post/3,4`, `gun:put/3,4` and `gun:patch/3,4`
+do not take a body in their arguments: the body must be
+provided later on using the `gun:data/4` function.
+
+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.
+
+.POST "/organizations/ninenines" with delayed body
+[source,erlang]
+----
+Body = "{\"msg\": \"Hello world!\"}",
+StreamRef = gun:post(ConnPid, "/organizations/ninenines", [
+ {<<"content-length">>, integer_to_binary(length(Body))},
+ {<<"content-type">>, "application/json"}
+]),
+gun:data(ConnPid, StreamRef, fin, Body).
+----
+
+The atom `fin` indicates this is the last chunk of data to
+be sent. You can call the `gun:data/4` function as many
+times as needed until you have sent the entire body. The
+last call must use `fin` and all the previous calls must
+use `nofin`. The last chunk may be empty.
+
+.Streaming the request body
+[source,erlang]
+----
+sendfile(ConnPid, StreamRef, Filepath) ->
+ {ok, IoDevice} = file:open(Filepath, [read, binary, raw]),
+ do_sendfile(ConnPid, StreamRef, IoDevice).
+
+do_sendfile(ConnPid, StreamRef, IoDevice) ->
+ case file:read(IoDevice, 8000) of
+ eof ->
+ gun:data(ConnPid, StreamRef, fin, <<>>),
+ file:close(IoDevice);
+ {ok, Bin} ->
+ gun:data(ConnPid, StreamRef, nofin, Bin),
+ do_sendfile(ConnPid, StreamRef, IoDevice)
+ end.
+----
+
+==== DELETE
+
+Use `gun:delete/2,3,4` to delete a resource.
+
+.DELETE "/organizations/ninenines"
+[source,erlang]
+----
+StreamRef = gun:delete(ConnPid, "/organizations/ninenines").
+----
+
+.DELETE "/organizations/ninenines" with custom headers
+[source,erlang]
+----
+StreamRef = gun:delete(ConnPid, "/organizations/ninenines", [
+ {<<"user-agent">>, "revolver/1.0"}
+]).
+----
+
+==== OPTIONS
+
+Use `gun:options/2,3` to request information about a resource.
+
+.OPTIONS "/organizations/ninenines"
+[source,erlang]
+----
+StreamRef = gun:options(ConnPid, "/organizations/ninenines").
+----
+
+.OPTIONS "/organizations/ninenines" with custom headers
+[source,erlang]
+----
+StreamRef = gun:options(ConnPid, "/organizations/ninenines", [
+ {<<"user-agent">>, "revolver/1.0"}
+]).
+----
+
+You can also use this function to request information about
+the server itself.
+
+.OPTIONS "*"
+[source,erlang]
+----
+StreamRef = gun:options(ConnPid, "*").
+----
+
+==== Requests with an arbitrary method
+
+The functions `gun:headers/4,5` or `gun:request/5,6` 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.
+
+.Example of a TRACE request
+[source,erlang]
+----
+gun:request(ConnPid, "TRACE", "/", [
+ {<<"max-forwards">>, "30"}
+], <<>>).
+----
+
+=== Processing responses
+
+All data received from the server is sent to the calling
+process as a message. First a `gun_response` message is sent,
+followed by zero or more `gun_data` messages. If something goes wrong,
+a `gun_error` message is sent instead.
+
+The response message will inform you whether there will be
+data messages following. If it contains `fin` there will be
+no data messages. If it contains `nofin` then one or more data
+messages will follow.
+
+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.
+
+You can receive messages directly, or you can use the _await_
+functions to let Gun receive them for you.
+
+.Receiving a response using receive
+[source,erlang]
+----
+print_body(ConnPid, MRef) ->
+ StreamRef = gun:get(ConnPid, "/"),
+ receive
+ {gun_response, ConnPid, StreamRef, fin, Status, Headers} ->
+ no_data;
+ {gun_response, ConnPid, StreamRef, nofin, Status, Headers} ->
+ receive_data(ConnPid, MRef, StreamRef);
+ {'DOWN', MRef, process, ConnPid, Reason} ->
+ error_logger:error_msg("Oops!"),
+ exit(Reason)
+ after 1000 ->
+ exit(timeout)
+ end.
+
+receive_data(ConnPid, MRef, StreamRef) ->
+ receive
+ {gun_data, ConnPid, StreamRef, nofin, Data} ->
+ io:format("~s~n", [Data]),
+ receive_data(ConnPid, MRef, StreamRef);
+ {gun_data, ConnPid, StreamRef, fin, Data} ->
+ io:format("~s~n", [Data]);
+ {'DOWN', MRef, process, ConnPid, Reason} ->
+ error_logger:error_msg("Oops!"),
+ exit(Reason)
+ after 1000 ->
+ exit(timeout)
+ end.
+----
+
+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.
+
+You can also use Gun in a synchronous manner by using the _await_
+functions.
+
+The `gun:await/2,3,4` function will wait until it receives
+a response to, a pushed resource related to, or data from
+the given stream.
+
+When calling `gun:await/2,3` and not passing a monitor
+reference, one is automatically created for you for the
+duration of the call.
+
+The `gun:await_body/2,3,4` works similarly, but returns the
+body received. Both functions can be combined to receive the
+response and its body sequentially.
+
+.Receiving a response using await
+[source,erlang]
+----
+StreamRef = gun:get(ConnPid, "/"),
+case gun:await(ConnPid, StreamRef) of
+ {response, fin, Status, Headers} ->
+ no_data;
+ {response, nofin, Status, Headers} ->
+ {ok, Body} = gun:await_body(ConnPid, StreamRef),
+ io:format("~s~n", [Body])
+end.
+----
+
+=== Handling streams pushed by the server
+
+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 `gun_push` messages before `gun_response`
+when that happens.
+
+You can safely choose to ignore `gun_push` messages, or
+you can handle them. If you do, you can either receive the
+messages directly or use _await_ functions.
+
+The `gun_push` message contains both the new stream reference
+and the stream reference of the original request.
+
+.Receiving a pushed response using receive
+[source,erlang]
+----
+receive
+ {gun_push, ConnPid, OriginalStreamRef, PushedStreamRef,
+ Method, Host, Path, Headers} ->
+ enjoy()
+end.
+----
+
+If you use the `gun:await/2,3,4` function, however, Gun
+will use the original reference to identify the message but
+will return a tuple that doesn't contain it.
+
+.Receiving a pushed response using await
+[source,erlang]
+----
+{push, PushedStreamRef, Method, URI, Headers}
+ = gun:await(ConnPid, OriginalStreamRef).
+----
+
+The `PushedStreamRef` variable can then be used with `gun:await/2,3,4`
+and `gun:await_body/2,3,4`.
+
+=== Flushing unwanted messages
+
+Gun provides the function `gun:flush/1` 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.
+
+.Flush all messages from a Gun connection
+[source,erlang]
+----
+gun:flush(ConnPid).
+----
+
+.Flush all messages from a specific stream
+[source,erlang]
+----
+gun:flush(StreamRef).
+----
+
+=== Redirecting responses to a different process
+
+Gun allows you to specify which process will handle responses
+to a request via the `reply_to` request option.
+
+.GET "/organizations/ninenines" to a different process
+[source,erlang]
+----
+StreamRef = gun:get(ConnPid, "/organizations/ninenines", [],
+ #{reply_to => Pid}).
+----
diff --git a/docs/en/gun/2.1/guide/http/index.html b/docs/en/gun/2.1/guide/http/index.html
new file mode 100644
index 00000000..435b1ee1
--- /dev/null
+++ b/docs/en/gun/2.1/guide/http/index.html
@@ -0,0 +1,452 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: HTTP</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>HTTP</span></h1>
+
+<p>This chapter describes how to use the Gun client for communicating with an HTTP/1.1 or HTTP/2 server.</p>
+<h2 id="_streams">Streams</h2>
+<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 and must be used to perform additional operations with a stream or to identify its messages.</p>
+<p>Stream references use the Erlang <em>reference</em> data type and are therefore unique.</p>
+<p>Streams can be canceled at any time. This will stop any further messages from being sent to the calling process. Depending on its capabilities, the server will also be instructed to cancel the request.</p>
+<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 class="listingblock"><div class="title">Cancelling a stream</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">gun:cancel</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<h2 id="_sending_requests">Sending requests</h2>
+<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>
+<p>The availability of these methods on the server can vary depending on the software used but also on a per-resource basis.</p>
+<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>
+<p>This section focuses on the act of sending a request. The handling of responses will be explained further on.</p>
+<h4 id="_get_and_head">GET and HEAD</h4>
+<p>Use <code>gun:get/2,3,4</code> to request a resource.</p>
+<div class="listingblock"><div class="title">GET &quot;/organizations/ninenines&quot;</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:get</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<div class="listingblock"><div class="title">GET &quot;/organizations/ninenines&quot; with custom headers</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:get</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>, [
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"accept"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"application/json"</font>},
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"user-agent"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"revolver/1.0"</font>}
+])<font color="#990000">.</font></tt></pre>
+</div></div>
+<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>
+<p>Use <code>gun:head/2,3,4</code> if you don&apos;t need the response body.</p>
+<div class="listingblock"><div class="title">HEAD &quot;/organizations/ninenines&quot;</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:head</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<div class="listingblock"><div class="title">HEAD &quot;/organizations/ninenines&quot; with custom headers</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:head</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>, [
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"accept"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"application/json"</font>},
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"user-agent"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"revolver/1.0"</font>}
+])<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>It is not possible to send a request body with a GET or HEAD request.</p>
+<h4 id="_post__put_and_patch">POST, PUT and PATCH</h4>
+<p>HTTP defines three methods to create or update a resource.</p>
+<p>POST is generally used when the resource identifier (URI) isn&apos;t known in advance when creating a resource. POST can also be used to replace an existing resource, although PUT is more appropriate in that situation.</p>
+<p>PUT creates or replaces a resource identified by the URI.</p>
+<p>PATCH provides instructions on how to modify the resource.</p>
+<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>
+<p>The functions <code>gun:post/4,5</code>, <code>gun:put/4,5</code> and <code>gun:patch/4,5</code> 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>
+<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 class="listingblock"><div class="title">POST &quot;/organizations/ninenines&quot;</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">Body</font> <font color="#990000">=</font> <font color="#FF0000">"{\"msg\": \"Hello world!\"}"</font>,
+<font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:post</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>, [
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"content-type"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"application/json"</font>}
+], <font color="#009900">Body</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>The functions <code>gun:post/3,4</code>, <code>gun:put/3,4</code> and <code>gun:patch/3,4</code> do not take a body in their arguments: the body must be provided later on using the <code>gun:data/4</code> function.</p>
+<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 class="listingblock"><div class="title">POST &quot;/organizations/ninenines&quot; with delayed body</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">Body</font> <font color="#990000">=</font> <font color="#FF0000">"{\"msg\": \"Hello world!\"}"</font>,
+<font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:post</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>, [
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"content-length"</font><font color="#990000">&gt;&gt;</font>, <b><font color="#000000">integer_to_binary</font></b>(<b><font color="#000080">length</font></b>(<font color="#009900">Body</font>))},
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"content-type"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"application/json"</font>}
+]),
+<b><font color="#000000">gun:data</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#FF6600">fin</font>, <font color="#009900">Body</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<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 class="listingblock"><div class="title">Streaming the request body</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">sendfile</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#009900">Filepath</font>) <font color="#990000">-&gt;</font>
+ {<font color="#FF6600">ok</font>, <font color="#009900">IoDevice</font>} <font color="#990000">=</font> <b><font color="#000000">file:open</font></b>(<font color="#009900">Filepath</font>, [<font color="#FF6600">read</font>, <b><font color="#000080">binary</font></b>, <font color="#FF6600">raw</font>]),
+ <b><font color="#000000">do_sendfile</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#009900">IoDevice</font>)<font color="#990000">.</font>
+
+<b><font color="#000000">do_sendfile</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#009900">IoDevice</font>) <font color="#990000">-&gt;</font>
+ <b><font color="#0000FF">case</font></b> <b><font color="#000000">file:read</font></b>(<font color="#009900">IoDevice</font>, <font color="#993399">8000</font>) <b><font color="#0000FF">of</font></b>
+ <font color="#FF6600">eof</font> <font color="#990000">-&gt;</font>
+ <b><font color="#000000">gun:data</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#FF6600">fin</font>, <font color="#990000">&lt;&lt;&gt;&gt;</font>),
+ <b><font color="#000000">file:close</font></b>(<font color="#009900">IoDevice</font>);
+ {<font color="#FF6600">ok</font>, <font color="#009900">Bin</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">gun:data</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#FF6600">nofin</font>, <font color="#009900">Bin</font>),
+ <b><font color="#000000">do_sendfile</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#009900">IoDevice</font>)
+ <b><font color="#0000FF">end</font></b><font color="#990000">.</font></tt></pre>
+</div></div>
+<h4 id="_delete">DELETE</h4>
+<p>Use <code>gun:delete/2,3,4</code> to delete a resource.</p>
+<div class="listingblock"><div class="title">DELETE &quot;/organizations/ninenines&quot;</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:delete</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<div class="listingblock"><div class="title">DELETE &quot;/organizations/ninenines&quot; with custom headers</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:delete</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>, [
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"user-agent"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"revolver/1.0"</font>}
+])<font color="#990000">.</font></tt></pre>
+</div></div>
+<h4 id="_options">OPTIONS</h4>
+<p>Use <code>gun:options/2,3</code> to request information about a resource.</p>
+<div class="listingblock"><div class="title">OPTIONS &quot;/organizations/ninenines&quot;</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:options</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<div class="listingblock"><div class="title">OPTIONS &quot;/organizations/ninenines&quot; with custom headers</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:options</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>, [
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"user-agent"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"revolver/1.0"</font>}
+])<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>You can also use this function to request information about the server itself.</p>
+<div class="listingblock"><div class="title">OPTIONS &quot;*&quot;</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:options</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"*"</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<h4 id="_requests_with_an_arbitrary_method">Requests with an arbitrary method</h4>
+<p>The functions <code>gun:headers/4,5</code> or <code>gun:request/5,6</code> 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 class="listingblock"><div class="title">Example of a TRACE request</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">gun:request</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"TRACE"</font>, <font color="#FF0000">"/"</font>, [
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"max-forwards"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"30"</font>}
+], <font color="#990000">&lt;&lt;&gt;&gt;</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<h2 id="_processing_responses">Processing responses</h2>
+<p>All data received from the server is sent to the calling 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>
+<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>
+<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>
+<p>You can receive messages directly, or you can use the <em>await</em> functions to let Gun receive them for you.</p>
+<div class="listingblock"><div class="title">Receiving a response using receive</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">print_body</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">MRef</font>) <font color="#990000">-&gt;</font>
+ <font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:get</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/"</font>),
+ <b><font color="#0000FF">receive</font></b>
+ {<font color="#FF6600">gun_response</font>, <font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#FF6600">fin</font>, <font color="#009900">Status</font>, <font color="#009900">Headers</font>} <font color="#990000">-&gt;</font>
+ <font color="#FF6600">no_data</font>;
+ {<font color="#FF6600">gun_response</font>, <font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#FF6600">nofin</font>, <font color="#009900">Status</font>, <font color="#009900">Headers</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">receive_data</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">MRef</font>, <font color="#009900">StreamRef</font>);
+ {<font color="#FF6600">'DOWN'</font>, <font color="#009900">MRef</font>, <b><font color="#000080">process</font></b>, <font color="#009900">ConnPid</font>, <font color="#009900">Reason</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">error_logger:error_msg</font></b>(<font color="#FF0000">"Oops!"</font>),
+ <b><font color="#000080">exit</font></b>(<font color="#009900">Reason</font>)
+ <b><font color="#0000FF">after</font></b> <font color="#993399">1000</font> <font color="#990000">-&gt;</font>
+ <b><font color="#000080">exit</font></b>(<font color="#FF6600">timeout</font>)
+ <b><font color="#0000FF">end</font></b><font color="#990000">.</font>
+
+<b><font color="#000000">receive_data</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">MRef</font>, <font color="#009900">StreamRef</font>) <font color="#990000">-&gt;</font>
+ <b><font color="#0000FF">receive</font></b>
+ {<font color="#FF6600">gun_data</font>, <font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#FF6600">nofin</font>, <font color="#009900">Data</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">io:format</font></b>(<font color="#FF0000">"~s~n"</font>, [<font color="#009900">Data</font>]),
+ <b><font color="#000000">receive_data</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">MRef</font>, <font color="#009900">StreamRef</font>);
+ {<font color="#FF6600">gun_data</font>, <font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#FF6600">fin</font>, <font color="#009900">Data</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">io:format</font></b>(<font color="#FF0000">"~s~n"</font>, [<font color="#009900">Data</font>]);
+ {<font color="#FF6600">'DOWN'</font>, <font color="#009900">MRef</font>, <b><font color="#000080">process</font></b>, <font color="#009900">ConnPid</font>, <font color="#009900">Reason</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">error_logger:error_msg</font></b>(<font color="#FF0000">"Oops!"</font>),
+ <b><font color="#000080">exit</font></b>(<font color="#009900">Reason</font>)
+ <b><font color="#0000FF">after</font></b> <font color="#993399">1000</font> <font color="#990000">-&gt;</font>
+ <b><font color="#000080">exit</font></b>(<font color="#FF6600">timeout</font>)
+ <b><font color="#0000FF">end</font></b><font color="#990000">.</font></tt></pre>
+</div></div>
+<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>
+<p>You can also use Gun in a synchronous manner by using the <em>await</em> functions.</p>
+<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>
+<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>
+<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 class="listingblock"><div class="title">Receiving a response using await</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:get</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/"</font>),
+<b><font color="#0000FF">case</font></b> <b><font color="#000000">gun:await</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>) <b><font color="#0000FF">of</font></b>
+ {<font color="#FF6600">response</font>, <font color="#FF6600">fin</font>, <font color="#009900">Status</font>, <font color="#009900">Headers</font>} <font color="#990000">-&gt;</font>
+ <font color="#FF6600">no_data</font>;
+ {<font color="#FF6600">response</font>, <font color="#FF6600">nofin</font>, <font color="#009900">Status</font>, <font color="#009900">Headers</font>} <font color="#990000">-&gt;</font>
+ {<font color="#FF6600">ok</font>, <font color="#009900">Body</font>} <font color="#990000">=</font> <b><font color="#000000">gun:await_body</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>),
+ <b><font color="#000000">io:format</font></b>(<font color="#FF0000">"~s~n"</font>, [<font color="#009900">Body</font>])
+<b><font color="#0000FF">end</font></b><font color="#990000">.</font></tt></pre>
+</div></div>
+<h2 id="_handling_streams_pushed_by_the_server">Handling streams pushed by the server</h2>
+<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>
+<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>
+<p>The <code>gun_push</code> message contains both the new stream reference and the stream reference of the original request.</p>
+<div class="listingblock"><div class="title">Receiving a pushed response using receive</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#0000FF">receive</font></b>
+ {<font color="#FF6600">gun_push</font>, <font color="#009900">ConnPid</font>, <font color="#009900">OriginalStreamRef</font>, <font color="#009900">PushedStreamRef</font>,
+ <font color="#009900">Method</font>, <font color="#009900">Host</font>, <font color="#009900">Path</font>, <font color="#009900">Headers</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">enjoy</font></b>()
+<b><font color="#0000FF">end</font></b><font color="#990000">.</font></tt></pre>
+</div></div>
+<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&apos;t contain it.</p>
+<div class="listingblock"><div class="title">Receiving a pushed response using await</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<font color="#FF6600">push</font>, <font color="#009900">PushedStreamRef</font>, <font color="#009900">Method</font>, <font color="#009900">URI</font>, <font color="#009900">Headers</font>}
+ <font color="#990000">=</font> <b><font color="#000000">gun:await</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">OriginalStreamRef</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>The <code>PushedStreamRef</code> variable can then be used with <code>gun:await/2,3,4</code> and <code>gun:await_body/2,3,4</code>.</p>
+<h2 id="_flushing_unwanted_messages">Flushing unwanted messages</h2>
+<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 class="listingblock"><div class="title">Flush all messages from a Gun connection</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">gun:flush</font></b>(<font color="#009900">ConnPid</font>)<font color="#990000">.</font></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.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">gun:flush</font></b>(<font color="#009900">StreamRef</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<h2 id="_redirecting_responses_to_a_different_process">Redirecting responses to a different process</h2>
+<p>Gun allows you to specify which process will handle responses to a request via the <code>reply_to</code> request option.</p>
+<div class="listingblock"><div class="title">GET &quot;/organizations/ninenines&quot; to a different process</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:get</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/organizations/ninenines"</font>, [],
+ #{<font color="#0000FF">reply_to</font> <font color="#990000">=&gt;</font> <font color="#009900">Pid</font>})<font color="#990000">.</font></tt></pre>
+</div></div>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/connect/">
+ Connection
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/websocket/">
+ Websocket
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/index.html b/docs/en/gun/2.1/guide/index.html
new file mode 100644
index 00000000..4d5cfe6a
--- /dev/null
+++ b/docs/en/gun/2.1/guide/index.html
@@ -0,0 +1,188 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Gun User Guide</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Gun User Guide</span></h1>
+
+<h2 id="_interface">Interface</h2>
+<ul><li><a href="introduction/">Introduction</a>
+</li>
+<li><a href="start/">Starting and stopping</a>
+</li>
+<li><a href="protocols/">Supported protocols</a>
+</li>
+<li><a href="connect/">Connection</a>
+</li>
+<li><a href="http/">Using HTTP</a>
+</li>
+<li><a href="websocket/">Using Websocket</a>
+</li>
+</ul>
+<h2 id="_advanced">Advanced</h2>
+<ul><li><a href="internals_tls_over_tls/">Internals: TLS over TLS</a>
+</li>
+</ul>
+<h2 id="_additional_information">Additional information</h2>
+<ul><li><a href="migrating_from_2.0/">Changes since Gun 2.0</a>
+</li>
+<li><a href="migrating_from_1.3/">Migrating from Gun 1.3 to 2.0</a>
+</li>
+<li><a href="migrating_from_1.2/">Migrating from Gun 1.2 to 1.3</a>
+</li>
+<li><a href="migrating_from_1.1/">Migrating from Gun 1.1 to 1.2</a>
+</li>
+<li><a href="migrating_from_1.0/">Migrating from Gun 1.0 to 1.1</a>
+</li>
+</ul>
+
+
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/internals_tls_over_tls.asciidoc b/docs/en/gun/2.1/guide/internals_tls_over_tls.asciidoc
new file mode 100644
index 00000000..07e86698
--- /dev/null
+++ b/docs/en/gun/2.1/guide/internals_tls_over_tls.asciidoc
@@ -0,0 +1,177 @@
+== Internals: TLS over TLS
+
+The `ssl` application that comes with Erlang/OTP implements
+TLS using an interface equivalent to the `gen_tcp` interface:
+you get and manipulate a socket. The TLS encoding and
+decoding is applied transparently to the data sent and
+received.
+
+In order to have a TLS layer inside another TLS layer we
+need a way to encode the data of the inner layer before
+we pass it to the outer layer. We cannot do this with
+a socket interface. Thankfully, the `ssl` application comes
+with options that allow to transform an `sslsocket()` into
+an encoder/decoder.
+
+The implementation is however a little convoluted as a
+result. This chapter aims to give an overview of how it
+all works under the hood.
+
+=== gun_tls_proxy
+
+The module `gun_tls_proxy` implements an intermediary process
+that sits between the Gun process and the TLS process. It is
+responsible for routing data from the Gun process to the TLS
+process, and from the TLS process to the Gun process.
+
+In order to obtain the TLS encoded data the `cb_info` option
+is given to the `ssl:connect/3` function. This replaces the
+default TCP outer socket module with our own custom module.
+Gun uses the `gun_tls_proxy_cb` module instead. This module
+will forward all messages to the `gun_tls_proxy` process.
+
+The resulting operations looks like this:
+
+----
+Gun process <-> gun_tls_proxy <-> sslsocket() <-> gun_tls_proxy <-> "inner socket"
+----
+
+The "inner socket" is the socket for the Gun connection.
+The `gun_tls_proxy` process decides where to send or
+receive the data based on where it's coming from. This
+is how it knows whether the data has been encoded/decoded
+or not.
+
+Because the `ssl:connect/3` function call is blocking,
+a temporary process is used while connecting. This is required
+because the `gun_tls_proxy` needs to forward data even while
+performing the TLS handshake, otherwise the `ssl:connect/3`
+call will not complete.
+
+The result of the `ssl:connect/3` call is forward to the Gun
+process, along with the negotiated protocols when the connection
+was successful.
+
+The `gun_tls_proxy_cb` module does not actually implement
+`{active,N}` as requested by the `ssl` application. Instead
+it uses `{active,true}`.
+
+The behavior of the `gun_tls_proxy` process will vary depending
+on whether the TLS over TLS is done connection-wide or only
+stream-wide.
+
+=== Connection-wide TLS over TLS
+
+When used for the entire connection, the `gun_tls_proxy` process
+will act like a real socket once connected. The only difference
+is how the connection is performed. As mentioned earlier, the
+result of the `ssl:connect/3` call is sent back to the Gun process.
+
+When doing TLS over TLS the processes will end up looking like
+this:
+
+----
+Gun process <-> gun_tls_proxy <-> "inner socket"
+----
+
+The details of the interactions between `gun_tls_proxy` and
+its associated `sslsocket()` have been removed in order to
+better illustrate the concept.
+
+When adding another layer this becomes:
+
+----
+Gun process <-> gun_tls_proxy <-> gun_tls_proxy <-> sslsocket()
+----
+
+This is what is done when only HTTP/1.1 and SOCKS proxies are
+involved.
+
+=== Stream-wide TLS over TLS
+
+The same cannot be done for HTTP/2 proxies. This is because the
+HTTP/2 CONNECT method does not apply to the entire connection,
+but only to a stream. The proxied data must be wrapped inside
+a DATA frame. It cannot be sent directly. This is what must be
+done:
+
+----
+Gun process -> gun_tls_proxy -> Gun process -> "inner socket"
+----
+
+The "inner socket" is the socket for the HTTP/2 connection.
+
+In order to tell Gun to continue processing the data, the
+`handle_continue` mechanism is introduced. When `gun_tls_proxy`
+has TLS encoded the data it sends it back to the Gun process,
+wrapped in a `handle_continue` tuple. This tuple contains
+enough information to figure out what stream the data belongs
+to and what should be done next. Gun will therefore route the
+data to the correct layer and continue sending it.
+
+This solution is also used for receiving data, except in the
+reverse order.
+
+=== Routing to the right stream
+
+In order to know where to route the data, the `stream_ref`
+had to be modified to contain all the references to the
+individual streams. So if the tunnel is identified by
+`StreamA` and a request on this tunnel is identified
+by `StreamB`, then the stream is known as `[StreamA, StreamB]`
+to the user. Gun then routes first to `StreamA`, a
+tunnel, which continues routing to `StreamB`.
+
+A problem comes up if an intermediary is a SOCKS server,
+for example in the following scenario:
+
+----
+HTTP/2 proxy <-> SOCKS proxy <-> HTTP/1.1 origin
+----
+
+The SOCKS protocol doesn't have a concept of stream,
+therefore when we refer to request to the origin server
+they are `[StreamA, StreamB]`, not `[StreamA, StreamB, StreamC]`.
+This is a problem for routing encoded/decoded TLS data
+to the SOCKS layer: we don't have a built-in way of referring
+to the SOCKS layer.
+
+The solution is to have a separate `handle_continue_stream_ref`
+value that assigns a reference to the SOCKS layers. Gun will
+then be able to forward `handle_continue` message, and only
+them, to the appropriate layer.
+
+Gun therefore has two different routing avenues, but the
+mechanism remains the same otherwise.
+
+=== gun_tunnel
+
+In order to simplify the routing, the `gun_tunnel` module
+was introduced. For each intermediary (including the original
+CONNECT stream at the HTTP/2 layer) there is a `gun_tunnel`
+module.
+
+Going back to the example above:
+
+----
+HTTP/2 proxy <-> SOCKS proxy <-> HTTP/1.1 origin
+----
+
+In this case the modules involved to handle the request
+will be as follow:
+
+----
+gun_http2 <-> gun_tunnel <-> gun_tunnel <-> gun_http
+----
+
+The `gun_http2` module doesn't do any routing, it just
+passes everything to the `gun_tunnel` module. The `gun_tunnel`
+module will then do the routing, which involves removing
+`StreamA` from `[StreamA, StreamB]` where appropriate.
+
+The `gun_tunnel` module also receives the TLS encoded/decoded
+data and forwards it appropriately. When it comes to sending
+data, it will return a `send` command that allows the previous
+module to continue sending the data. The `gun_http2` module
+will ultimately wrap the data to be sent in a DATA frame and
+send it to the "inner socket".
diff --git a/docs/en/gun/2.1/guide/internals_tls_over_tls/index.html b/docs/en/gun/2.1/guide/internals_tls_over_tls/index.html
new file mode 100644
index 00000000..e62b3326
--- /dev/null
+++ b/docs/en/gun/2.1/guide/internals_tls_over_tls/index.html
@@ -0,0 +1,222 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Internals: TLS over TLS</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Internals: TLS over TLS</span></h1>
+
+<p>The <code>ssl</code> application that comes with Erlang/OTP implements TLS using an interface equivalent to the <code>gen_tcp</code> interface: you get and manipulate a socket. The TLS encoding and decoding is applied transparently to the data sent and received.</p>
+<p>In order to have a TLS layer inside another TLS layer we need a way to encode the data of the inner layer before we pass it to the outer layer. We cannot do this with a socket interface. Thankfully, the <code>ssl</code> application comes with options that allow to transform an <code>sslsocket()</code> into an encoder/decoder.</p>
+<p>The implementation is however a little convoluted as a result. This chapter aims to give an overview of how it all works under the hood.</p>
+<h2 id="_gun_tls_proxy">gun_tls_proxy</h2>
+<p>The module <code>gun_tls_proxy</code> implements an intermediary process that sits between the Gun process and the TLS process. It is responsible for routing data from the Gun process to the TLS process, and from the TLS process to the Gun process.</p>
+<p>In order to obtain the TLS encoded data the <code>cb_info</code> option is given to the <code>ssl:connect/3</code> function. This replaces the default TCP outer socket module with our own custom module. Gun uses the <code>gun_tls_proxy_cb</code> module instead. This module will forward all messages to the <code>gun_tls_proxy</code> process.</p>
+<p>The resulting operations looks like this:</p>
+<div class="listingblock"><div class="content"><pre>Gun process &lt;-&gt; gun_tls_proxy &lt;-&gt; sslsocket() &lt;-&gt; gun_tls_proxy &lt;-&gt; &quot;inner socket&quot;</pre></div></div>
+<p>The &quot;inner socket&quot; is the socket for the Gun connection. The <code>gun_tls_proxy</code> process decides where to send or receive the data based on where it&apos;s coming from. This is how it knows whether the data has been encoded/decoded or not.</p>
+<p>Because the <code>ssl:connect/3</code> function call is blocking, a temporary process is used while connecting. This is required because the <code>gun_tls_proxy</code> needs to forward data even while performing the TLS handshake, otherwise the <code>ssl:connect/3</code> call will not complete.</p>
+<p>The result of the <code>ssl:connect/3</code> call is forward to the Gun process, along with the negotiated protocols when the connection was successful.</p>
+<p>The <code>gun_tls_proxy_cb</code> module does not actually implement <code>{active,N}</code> as requested by the <code>ssl</code> application. Instead it uses <code>{active,true}</code>.</p>
+<p>The behavior of the <code>gun_tls_proxy</code> process will vary depending on whether the TLS over TLS is done connection-wide or only stream-wide.</p>
+<h2 id="_connection_wide_tls_over_tls">Connection-wide TLS over TLS</h2>
+<p>When used for the entire connection, the <code>gun_tls_proxy</code> process will act like a real socket once connected. The only difference is how the connection is performed. As mentioned earlier, the result of the <code>ssl:connect/3</code> call is sent back to the Gun process.</p>
+<p>When doing TLS over TLS the processes will end up looking like this:</p>
+<div class="listingblock"><div class="content"><pre>Gun process &lt;-&gt; gun_tls_proxy &lt;-&gt; &quot;inner socket&quot;</pre></div></div>
+<p>The details of the interactions between <code>gun_tls_proxy</code> and its associated <code>sslsocket()</code> have been removed in order to better illustrate the concept.</p>
+<p>When adding another layer this becomes:</p>
+<div class="listingblock"><div class="content"><pre>Gun process &lt;-&gt; gun_tls_proxy &lt;-&gt; gun_tls_proxy &lt;-&gt; sslsocket()</pre></div></div>
+<p>This is what is done when only HTTP/1.1 and SOCKS proxies are involved.</p>
+<h2 id="_stream_wide_tls_over_tls">Stream-wide TLS over TLS</h2>
+<p>The same cannot be done for HTTP/2 proxies. This is because the HTTP/2 CONNECT method does not apply to the entire connection, but only to a stream. The proxied data must be wrapped inside a DATA frame. It cannot be sent directly. This is what must be done:</p>
+<div class="listingblock"><div class="content"><pre>Gun process -&gt; gun_tls_proxy -&gt; Gun process -&gt; &quot;inner socket&quot;</pre></div></div>
+<p>The &quot;inner socket&quot; is the socket for the HTTP/2 connection.</p>
+<p>In order to tell Gun to continue processing the data, the <code>handle_continue</code> mechanism is introduced. When <code>gun_tls_proxy</code> has TLS encoded the data it sends it back to the Gun process, wrapped in a <code>handle_continue</code> tuple. This tuple contains enough information to figure out what stream the data belongs to and what should be done next. Gun will therefore route the data to the correct layer and continue sending it.</p>
+<p>This solution is also used for receiving data, except in the reverse order.</p>
+<h2 id="_routing_to_the_right_stream">Routing to the right stream</h2>
+<p>In order to know where to route the data, the <code>stream_ref</code> had to be modified to contain all the references to the individual streams. So if the tunnel is identified by <code>StreamA</code> and a request on this tunnel is identified by <code>StreamB</code>, then the stream is known as <code>[StreamA, StreamB]</code> to the user. Gun then routes first to <code>StreamA</code>, a tunnel, which continues routing to <code>StreamB</code>.</p>
+<p>A problem comes up if an intermediary is a SOCKS server, for example in the following scenario:</p>
+<div class="listingblock"><div class="content"><pre>HTTP/2 proxy &lt;-&gt; SOCKS proxy &lt;-&gt; HTTP/1.1 origin</pre></div></div>
+<p>The SOCKS protocol doesn&apos;t have a concept of stream, therefore when we refer to request to the origin server they are <code>[StreamA, StreamB]</code>, not <code>[StreamA, StreamB, StreamC]</code>. This is a problem for routing encoded/decoded TLS data to the SOCKS layer: we don&apos;t have a built-in way of referring to the SOCKS layer.</p>
+<p>The solution is to have a separate <code>handle_continue_stream_ref</code> value that assigns a reference to the SOCKS layers. Gun will then be able to forward <code>handle_continue</code> message, and only them, to the appropriate layer.</p>
+<p>Gun therefore has two different routing avenues, but the mechanism remains the same otherwise.</p>
+<h2 id="_gun_tunnel">gun_tunnel</h2>
+<p>In order to simplify the routing, the <code>gun_tunnel</code> module was introduced. For each intermediary (including the original CONNECT stream at the HTTP/2 layer) there is a <code>gun_tunnel</code> module.</p>
+<p>Going back to the example above:</p>
+<div class="listingblock"><div class="content"><pre>HTTP/2 proxy &lt;-&gt; SOCKS proxy &lt;-&gt; HTTP/1.1 origin</pre></div></div>
+<p>In this case the modules involved to handle the request will be as follow:</p>
+<div class="listingblock"><div class="content"><pre>gun_http2 &lt;-&gt; gun_tunnel &lt;-&gt; gun_tunnel &lt;-&gt; gun_http</pre></div></div>
+<p>The <code>gun_http2</code> module doesn&apos;t do any routing, it just passes everything to the <code>gun_tunnel</code> module. The <code>gun_tunnel</code> module will then do the routing, which involves removing <code>StreamA</code> from <code>[StreamA, StreamB]</code> where appropriate.</p>
+<p>The <code>gun_tunnel</code> module also receives the TLS encoded/decoded data and forwards it appropriately. When it comes to sending data, it will return a <code>send</code> command that allows the previous module to continue sending the data. The <code>gun_http2</code> module will ultimately wrap the data to be sent in a DATA frame and send it to the &quot;inner socket&quot;.</p>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/websocket/">
+ Websocket
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/migrating_from_2.0/">
+ Migrating from Gun 2.0 to 2.1
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/introduction.asciidoc b/docs/en/gun/2.1/guide/introduction.asciidoc
new file mode 100644
index 00000000..948dde95
--- /dev/null
+++ b/docs/en/gun/2.1/guide/introduction.asciidoc
@@ -0,0 +1,49 @@
+[[introduction]]
+== Introduction
+
+Gun is an HTTP client for Erlang/OTP.
+
+Gun supports the HTTP/2, HTTP/1.1 and Websocket protocols.
+
+=== Prerequisites
+
+Knowledge of Erlang, but also of the HTTP/1.1, HTTP/2 and Websocket
+protocols is required in order to read this guide.
+
+=== Supported platforms
+
+Gun is tested and supported on Linux, FreeBSD, Windows and OSX.
+
+Gun is developed for Erlang/OTP 22.0 and newer.
+
+=== License
+
+Gun uses the ISC License.
+
+----
+Copyright (c) 2013-2023, Loïc Hoguin <[email protected]>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+----
+
+=== Versioning
+
+Gun uses http://semver.org/[Semantic Versioning 2.0.0].
+
+=== Conventions
+
+In the HTTP protocol, the method name is case sensitive. All standard
+method names are uppercase.
+
+Header names are case insensitive. Gun converts all the header names
+to lowercase, including request headers provided by your application.
diff --git a/docs/en/gun/2.1/guide/introduction/index.html b/docs/en/gun/2.1/guide/introduction/index.html
new file mode 100644
index 00000000..b9fe742e
--- /dev/null
+++ b/docs/en/gun/2.1/guide/introduction/index.html
@@ -0,0 +1,203 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Introduction</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Introduction</span></h1>
+
+<p>Gun is an HTTP client for Erlang/OTP.</p>
+<p>Gun supports the HTTP/2, HTTP/1.1 and Websocket protocols.</p>
+<h2 id="_prerequisites">Prerequisites</h2>
+<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>
+<h2 id="_supported_platforms">Supported platforms</h2>
+<p>Gun is tested and supported on Linux, FreeBSD, Windows and OSX.</p>
+<p>Gun is developed for Erlang/OTP 22.0 and newer.</p>
+<h2 id="_license">License</h2>
+<p>Gun uses the ISC License.</p>
+<div class="listingblock"><div class="content"><pre>Copyright (c) 2013-2023, Loïc Hoguin &lt;[email protected]&gt;
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED &quot;AS IS&quot; AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</pre></div></div>
+<h2 id="_versioning">Versioning</h2>
+<p>Gun uses <a href="http://semver.org/">Semantic Versioning 2.0.0</a>.</p>
+<h2 id="_conventions">Conventions</h2>
+<p>In the HTTP protocol, the method name is case sensitive. All standard method names are uppercase.</p>
+<p>Header names are case insensitive. Gun converts all the header names to lowercase, including request headers provided by your application.</p>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/start/">
+ Starting and stopping
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/migrating_from_1.0.asciidoc b/docs/en/gun/2.1/guide/migrating_from_1.0.asciidoc
new file mode 100644
index 00000000..3a11cfd3
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_1.0.asciidoc
@@ -0,0 +1,21 @@
+[appendix]
+== Migrating from Gun 1.0 to 1.1
+
+Gun 1.1 updates the Cowlib dependency to 2.5.1 and fixes a
+few problems with experimental features.
+
+=== Features added
+
+* Update Cowlib to 2.5.1
+
+=== Bugs fixed
+
+* A bug in the experimental `gun_sse_h` where lone id lines
+ were not propagated has been fixed by updating the Cowlib
+ dependency.
+
+* The status code was incorrectly given to the experimental
+ content handlers as a binary. It has been fixed an an
+ integer is now given as was intended.
+
+* A number of Dialyzer warnings have been fixed.
diff --git a/docs/en/gun/2.1/guide/migrating_from_1.0/index.html b/docs/en/gun/2.1/guide/migrating_from_1.0/index.html
new file mode 100644
index 00000000..4bd8a35b
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_1.0/index.html
@@ -0,0 +1,189 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Migrating from Gun 1.0 to 1.1</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Migrating from Gun 1.0 to 1.1</span></h1>
+
+<p>Gun 1.1 updates the Cowlib dependency to 2.5.1 and fixes a few problems with experimental features.</p>
+<h2 id="_features_added">Features added</h2>
+<ul><li>Update Cowlib to 2.5.1
+</li>
+</ul>
+<h2 id="_bugs_fixed">Bugs fixed</h2>
+<ul><li>A bug in the experimental <code>gun_sse_h</code> where lone id lines were not propagated has been fixed by updating the Cowlib dependency.
+</li>
+<li>The status code was incorrectly given to the experimental content handlers as a binary. It has been fixed an an integer is now given as was intended.
+</li>
+<li>A number of Dialyzer warnings have been fixed.
+</li>
+</ul>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/migrating_from_1.1/">
+ Migrating from Gun 1.1 to 1.2
+ </a>
+
+
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/migrating_from_1.1.asciidoc b/docs/en/gun/2.1/guide/migrating_from_1.1.asciidoc
new file mode 100644
index 00000000..7e0acf9d
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_1.1.asciidoc
@@ -0,0 +1,28 @@
+[appendix]
+== Migrating from Gun 1.1 to 1.2
+
+Gun 1.2 adds support for the CONNECT request over HTTP/1.1
+connections.
+
+=== Features added
+
+* CONNECT requests can now be issued on HTTP/1.1 connections.
+ The tunneled connection can use any of the protocols Gun
+ supports: HTTP/1.1, HTTP/2 and Websocket over both TCP and
+ TLS transports. Note that Gun currently does not support
+ tunneling a TLS connection over a TLS connection due to
+ limitations in Erlang/OTP.
+
+* Gun supports sending multiple CONNECT requests, allowing
+ the tunnel to the origin server to go through multiple
+ proxies.
+
+* Gun supports sending CONNECT requests with authorization
+ credentials using the Basic authentication mechanism.
+
+* Update Cowlib to 2.6.0
+
+=== Functions added
+
+* The functions `gun:connect/2,3,4` have been added. They can
+ be used to initiate CONNECT requests on HTTP/1.1 connections.
diff --git a/docs/en/gun/2.1/guide/migrating_from_1.1/index.html b/docs/en/gun/2.1/guide/migrating_from_1.1/index.html
new file mode 100644
index 00000000..25270e2d
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_1.1/index.html
@@ -0,0 +1,195 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Migrating from Gun 1.1 to 1.2</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Migrating from Gun 1.1 to 1.2</span></h1>
+
+<p>Gun 1.2 adds support for the CONNECT request over HTTP/1.1 connections.</p>
+<h2 id="_features_added">Features added</h2>
+<ul><li>CONNECT requests can now be issued on HTTP/1.1 connections. The tunneled connection can use any of the protocols Gun supports: HTTP/1.1, HTTP/2 and Websocket over both TCP and TLS transports. Note that Gun currently does not support tunneling a TLS connection over a TLS connection due to limitations in Erlang/OTP.
+</li>
+<li>Gun supports sending multiple CONNECT requests, allowing the tunnel to the origin server to go through multiple proxies.
+</li>
+<li>Gun supports sending CONNECT requests with authorization credentials using the Basic authentication mechanism.
+</li>
+<li>Update Cowlib to 2.6.0
+</li>
+</ul>
+<h2 id="_functions_added">Functions added</h2>
+<ul><li>The functions <code>gun:connect/2,3,4</code> have been added. They can be used to initiate CONNECT requests on HTTP/1.1 connections.
+</li>
+</ul>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/migrating_from_1.2/">
+ Migrating from Gun 1.2 to 1.3
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/migrating_from_1.0/">
+ Migrating from Gun 1.0 to 1.1
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/migrating_from_1.2.asciidoc b/docs/en/gun/2.1/guide/migrating_from_1.2.asciidoc
new file mode 100644
index 00000000..3b310920
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_1.2.asciidoc
@@ -0,0 +1,39 @@
+[appendix]
+== Migrating from Gun 1.2 to 1.3
+
+Gun 1.3 improves the support for CONNECT requests
+introduced in the previous version and documents
+Websocket protocol negotiation.
+
+=== Features added
+
+* The `protocols` CONNECT destination option has been added
+ as a replacement for the now deprecated `protocol` option.
+
+* Add built-in support for Websocket protocol negotiation
+ through the Websocket option `protocols`. The interface
+ of the handler module currently remains undocumented and
+ must be set to `gun_ws_h`.
+
+* Add the h2specd HTTP/2 test suite from the h2spec project.
+
+=== Bugs fixed
+
+* Fix connecting to HTTP/2 over TLS origin servers via
+ HTTP/1.1 CONNECT proxies.
+
+* Do not send the HTTP/1.1 keepalive while waiting for
+ a response to a CONNECT request.
+
+* Do not crash on HTTP/2 HEADERS frames with the
+ PRIORITY flag set.
+
+* Do not crash on HTTP/2 HEADERS frames when the
+ END_HEADERS flag is not set.
+
+* Do not crash on unknown HTTP/2 frame types.
+
+* Reject HTTP/2 WINDOW_UPDATE frames when they would
+ cause the window to overflow.
+
+* Send a GOAWAY frame on closing the HTTP/2 connection.
diff --git a/docs/en/gun/2.1/guide/migrating_from_1.2/index.html b/docs/en/gun/2.1/guide/migrating_from_1.2/index.html
new file mode 100644
index 00000000..b29a4fab
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_1.2/index.html
@@ -0,0 +1,205 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Migrating from Gun 1.2 to 1.3</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Migrating from Gun 1.2 to 1.3</span></h1>
+
+<p>Gun 1.3 improves the support for CONNECT requests introduced in the previous version and documents Websocket protocol negotiation.</p>
+<h2 id="_features_added">Features added</h2>
+<ul><li>The <code>protocols</code> CONNECT destination option has been added as a replacement for the now deprecated <code>protocol</code> option.
+</li>
+<li>Add built-in support for Websocket protocol negotiation through the Websocket option <code>protocols</code>. The interface of the handler module currently remains undocumented and must be set to <code>gun_ws_h</code>.
+</li>
+<li>Add the h2specd HTTP/2 test suite from the h2spec project.
+</li>
+</ul>
+<h2 id="_bugs_fixed">Bugs fixed</h2>
+<ul><li>Fix connecting to HTTP/2 over TLS origin servers via HTTP/1.1 CONNECT proxies.
+</li>
+<li>Do not send the HTTP/1.1 keepalive while waiting for a response to a CONNECT request.
+</li>
+<li>Do not crash on HTTP/2 HEADERS frames with the PRIORITY flag set.
+</li>
+<li>Do not crash on HTTP/2 HEADERS frames when the END_HEADERS flag is not set.
+</li>
+<li>Do not crash on unknown HTTP/2 frame types.
+</li>
+<li>Reject HTTP/2 WINDOW_UPDATE frames when they would cause the window to overflow.
+</li>
+<li>Send a GOAWAY frame on closing the HTTP/2 connection.
+</li>
+</ul>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/migrating_from_1.3/">
+ Migrating from Gun 1.3 to 2.0
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/migrating_from_1.1/">
+ Migrating from Gun 1.1 to 1.2
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/migrating_from_1.3.asciidoc b/docs/en/gun/2.1/guide/migrating_from_1.3.asciidoc
new file mode 100644
index 00000000..59f3381c
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_1.3.asciidoc
@@ -0,0 +1,329 @@
+[appendix]
+== Migrating from Gun 1.3 to 2.0
+
+Gun 2.0 includes state of the art tunnel support. With
+Gun 2.0 it is possible to make requests or data go through
+any number of proxy endpoints using any combination of
+TCP or TLS transports and HTTP/1.1, HTTP/2 or SOCKS5
+protocols. All combinations of the scenario Proxy1 ->
+Proxy2 -> Origin are tested and known to work.
+
+Gun 2.0 adds many more features such as Websocket over
+HTTP/2, a built-in cookie store, graceful shutdown, flow
+control for data messages, event handlers and more.
+
+Gun 2.0 also introduces an experimental pool module that
+automatically maintains connections and routes requests
+to the right process, in a similar way as browsers do.
+
+Gun 2.0 greatly improves the HTTP/2 performance when it
+comes to receiving large response bodies; and when receiving
+response bodies from many separate requests concurrently.
+
+Gun now shares much of its HTTP/2 code with Cowboy,
+including the HTTP/2 state machine. Numerous issues were
+fixed as a result because the Cowboy implementation was
+much more advanced.
+
+The Gun connection process is now implemented using `gen_statem`.
+
+Gun 2.0 requires Erlang/OTP 22.0 or greater.
+
+=== Features added
+
+* Cookie store support has been added. The `cookie_store`
+ option allows configuring the cookie store backend.
+ The `gun_cookies` module provides functions to help
+ implementing such a backend. Gun comes with the backend
+ `gun_cookies_list` which provides a per-connection,
+ non-persistent cookie store. The cookie store engine
+ implements the entire RFC6265bis draft algorithms except
+ the parts about non-HTTP cookies as no such interface is
+ provided; and the parts about SameSite as Gun has no
+ concept of "browsing context".
+
+* Graceful shutdown has been implemented. Graceful shutdown
+ can be initiated on the client side by calling the new
+ function `gun:shutdown/1` or when the owner process goes
+ away; or on the peer side via the connection: close HTTP/1.1
+ header, the HTTP/2 GOAWAY frame or the Websocket close frame.
+ Gun will try to complete existing streams when possible;
+ other streams get canceled immediately. The `closing_timeout`
+ option controls how long we are willing to wait at most
+ before closing the connection.
+
+* Gun will better detect connection failures by checking the
+ return value from sending data to the socket. This applies
+ to all supported protocols. In addition, Gun now enables
+ `send_timeout_close` with a `send_timeout` value defaulting
+ to 15s.
+
+* Flow control has been added. It allows limiting the number
+ of data/Websocket messages Gun sends to the calling process.
+ Gun will stop reading from the socket or stop updating the
+ protocol's flow control window when applicable as well, to
+ apply some backpressure to the remote endpoint(s). It is
+ disabled by default and can be applied on a per-request
+ basis if necessary.
+
+* An event handler interface has been added providing access
+ to many internal Gun events. This can be used for a variety
+ of purposes including logging, tracing or otherwise
+ instrumenting a Gun connection.
+
+* In order to get separate events when connecting, the domain
+ lookup, connection and TLS handshakes are now performed
+ separately by Gun. As a result, there exists three separate
+ timeout options for each of the steps, and the transport
+ options had to be split into `tcp_opts` and `tls_opts`.
+
+* Gun now supports connecting through SOCKS proxies,
+ including secure SOCKS proxies. Both unauthenticated
+ and username/password authentication are supported.
+
+* Gun can connect through any number of HTTP, HTTPS, SOCKS
+ or secure SOCKS proxies, including SOCKS proxies
+ located after HTTP(S) proxies. The ultimate endpoint
+ may be using any protocol, including plain TCP, TLS,
+ HTTP/1.1 or HTTP/2.
+
+* When specifying which protocols to use, options can
+ now be provided specific to those protocols. It is
+ now possible to have separate HTTP options for an
+ HTTP proxy and the origin HTTP server, for example.
+ See the new `gun:protocols()` type for details.
+
+* Gun can now be used to send and receive raw data,
+ as if it was just a normal socket. This can be
+ useful when needing to connect through a number
+ of HTTP/Socks proxies, allowing the use of Gun's
+ great proxying capabilities (including TLS over TLS)
+ for any sort of protocols. This can also be useful
+ when performing HTTP/1.1 Upgrade to custom protocols.
+
+* Headers can now be provided as a map.
+
+* Header names may now be provided as binary, string or atom.
+
+* Gun now automatically lowercases provided header names.
+
+* Many HTTP/2 options have been added, allowing great
+ control over how Gun and the remote endpoint are
+ using the HTTP/2 connection. They can be used to
+ improve performance or lower the memory usage, for
+ example.
+
+* A new `keepalive_tolerance` option for HTTP/2 enables
+ closing the connection automatically when ping acks
+ are not received in a timely manner. It nicely
+ complements the `keepalive` option that makes Gun
+ send pings.
+
+* Gun now supports Websocket subprotocol negotiation
+ and the feature is fully documented and tested.
+ This can be used to create handlers that will
+ implement a protocol from within the Gun process itself.
+ The negotiation is enabled by setting the `protocols`
+ setting. The `default_protocol` and `user_opts`
+ settings are also useful.
+
+* It is now possible to send many Websocket frames in
+ a single `gun:ws_send/3` call.
+
+* Gun may now send Websocket ping frames automatically
+ at intervals determined by the `keepalive` option. It
+ is disabled by default.
+
+* A new `silence_pings` option can be set to `false` to
+ receive all ping and pong frames when using Websocket.
+ They are typically not needed and therefore silent by
+ default.
+
+* The `reply_to` option has been added to `gun:ws_upgrade/4`.
+ The option applies to both the response and subsequent
+ Websocket frames.
+
+* The `reply_to` option is also propagated to messages
+ following a CONNECT request when the protocol requested
+ is not HTTP.
+
+* A new option `retry_fun` can be used to implement
+ different backoff strategies when reconnecting.
+
+* A new option `supervise` can be used to start a Gun
+ connection without using Gun's supervisor. It defaults
+ to `true`.
+
+* Many improvements have been done to postpone or reject
+ requests and other operations while in the wrong state
+ (for example during state transitions when switching
+ protocols or connecting to proxies).
+
+* Update Cowlib to 2.12.0.
+
+=== Experimental features added
+
+* The `gun_pool` module was introduced. Its interface
+ is very similar to the `gun` module, but as it is an
+ experimental feature, it has not been documented yet.
+ The intent is to obtain feedback and document it in
+ an upcoming minor release. Pools are created for each
+ authority (host/port) and scope (user-defined value)
+ pairs and are resolved accordingly using the information
+ provided in the request and request options. Connections
+ may concurrently handle multiple requests/responses
+ from as many different processes as required.
+
+=== Features removed
+
+* Gun used to reject operations by processes that were not
+ the owner of the connection. This behavior has been removed.
+ In general the caller of a request or other operation will
+ receive the relevant messages unless the `reply_to` option
+ is used.
+
+* The `connect_destination()` option `protocol` has been
+ removed. It was previously deprecated in favor of `protocols`.
+
+* The `keepalive` timeout is now disabled by default
+ for HTTP/1.1 and HTTP/2. To be perfectly clear, this
+ is unrelated to the HTTP/1.1 keep-alive mechanism.
+
+=== Functions added
+
+* The function `gun:set_owner/2` has been added. It allows
+ changing the owner of a connection process. Only the current
+ owner can do this operation.
+
+* The function `gun:shutdown/1` has been added. It initiates
+ the graceful shutdown of the connection, followed by the
+ termination of the Gun process.
+
+* The function `gun:stream_info/2` has been added. It provides
+ information about a specific HTTP stream.
+
+=== Functions modified
+
+* The function `gun:info/1` now returns the owner of the
+ connection as well as the cookie store.
+
+* The functions `gun:await/2,3,4`, `gun:await_body/2,3,4` and
+ `gun:await_up/1,2,3` now distinguish the error types. They
+ can be a timeout, a connection error, a stream error or a
+ down error (when the Gun process exited while waiting).
+
+* The functions `gun:await/2,3,4` will now receive upgrades,
+ tunnel up and Websocket messages and return them.
+
+* Requests may now include the `tunnel` option to send the
+ request on a specific tunnel.
+
+* The functions `gun:request/4,5,6` have been replaced with
+ `gun:headers/4,5` and `gun:request/5,6`. This provides a
+ cleaner separation between requests that are followed by
+ a body and those that aren't.
+
+* The function `gun:ws_send/2` has been replaced with the
+ function `gun:ws_send/3`. The stream reference for the
+ corresponding Websocket upgrade request must now be given.
+
+=== Messages added
+
+* The `gun_tunnel_up` message has been added.
+
+=== Messages modified
+
+* The `gun_down` message no longer has its final element
+ documented as `UnprocessedStreams`. It never worked and
+ was always an empty list.
+
+=== Bugs fixed
+
+* *POTENTIAL SECURITY VULNERABILITY*: Fix transfer-encoding
+ precedence over content-length in responses. This bug may
+ contribute to a response smuggling security vulnerability
+ when Gun is used inside a proxy.
+
+* Gun will now better detect connection closes in some cases.
+
+* Gun will no longer send duplicate connection-wide `gun_error`
+ messages to the same process.
+
+* Gun no longer crashes when trying to upgrade to Websocket
+ over a connection restricted to HTTP/1.0.
+
+* The default value for the preferred protocols when using
+ CONNECT over TLS has been corrected. It was mistakenly not
+ enabling HTTP/2.
+
+* Protocol options provided for a tunnel destination were
+ sometimes ignored. This should no longer be the case.
+
+* Gun will no longer send an empty HTTP/2 DATA frame when
+ there is no request body. It was not necessary.
+
+* Gun will no longer error out when the owner process exits.
+ The error reason will now be a `shutdown` tuple instead.
+
+* The host header was set incorrectly during Websocket upgrades
+ when the host was configured with an IP address, resulting
+ in a crash. This has been corrected.
+
+* A completed stream could be found in the `gun_down` message when
+ the response contained a connection: close header. This is no
+ longer the case.
+
+* Hostnames can now be provided as atom as stated by the
+ documentation.
+
+* Gun will no longer attempt to send empty data chunks. When
+ using HTTP/1.1 chunked transfer-encoding this caused the
+ request body to end, even when `nofin` was given.
+
+* Gun now always retries connecting immediately when the
+ connection goes down.
+
+* The default port number for the HTTP and HTTPS schemes is
+ no longer sent in the host header.
+
+* An invalid stream reference was sent on failed Websocket
+ upgrade responses. This has been corrected.
+
+* HTTP/2 connection preface errors are now properly detected
+ and propagated in the `gun_down` message to the connection
+ owner as well as the exit reason of the Gun process.
+
+* HTTP/2 connection preface errors now provide a different
+ human readable error when the data received looks like an
+ HTTP/1.x response.
+
+* HTTP/2 connection errors were missing the human readable
+ reason in the `gun_error` message. This has been corrected.
+
+* Fix the host and :authority (pseudo-)headers when connecting
+ to an IPv6 address given as a tuple. They were lacking the
+ surrounding brackets.
+
+* Fix a crash in gun:info/1 when the socket was closed before
+ we call Transport:sockname/1.
+
+* Fix flushing by stream reference. When the `gun_inform`
+ message was flushed the function would switch to flushing
+ all messages from the pid instead of only messages from
+ the given stream.
+
+* Allow setting a custom SNI value.
+
+* Fix double sending of last chunk in HTTP/1.1 when Gun is
+ asked to send empty data before closing the stream.
+
+* Gun will now properly ignore parameters when the media
+ type is text/event-stream.
+
+* Avoid noisy crashes in the TLS over TLS code.
+
+* Gun will now include the StreamRef of Websocket streams
+ when sending `gun_down` messages.
+
+* Gun will no longer reject HTTP proxies that use HTTP/1.0
+ for the version in their response.
diff --git a/docs/en/gun/2.1/guide/migrating_from_1.3/index.html b/docs/en/gun/2.1/guide/migrating_from_1.3/index.html
new file mode 100644
index 00000000..c2a6acd3
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_1.3/index.html
@@ -0,0 +1,337 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Migrating from Gun 1.3 to 2.0</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Migrating from Gun 1.3 to 2.0</span></h1>
+
+<p>Gun 2.0 includes state of the art tunnel support. With Gun 2.0 it is possible to make requests or data go through any number of proxy endpoints using any combination of TCP or TLS transports and HTTP/1.1, HTTP/2 or SOCKS5 protocols. All combinations of the scenario Proxy1 -&gt; Proxy2 -&gt; Origin are tested and known to work.</p>
+<p>Gun 2.0 adds many more features such as Websocket over HTTP/2, a built-in cookie store, graceful shutdown, flow control for data messages, event handlers and more.</p>
+<p>Gun 2.0 also introduces an experimental pool module that automatically maintains connections and routes requests to the right process, in a similar way as browsers do.</p>
+<p>Gun 2.0 greatly improves the HTTP/2 performance when it comes to receiving large response bodies; and when receiving response bodies from many separate requests concurrently.</p>
+<p>Gun now shares much of its HTTP/2 code with Cowboy, including the HTTP/2 state machine. Numerous issues were fixed as a result because the Cowboy implementation was much more advanced.</p>
+<p>The Gun connection process is now implemented using <code>gen_statem</code>.</p>
+<p>Gun 2.0 requires Erlang/OTP 22.0 or greater.</p>
+<h2 id="_features_added">Features added</h2>
+<ul><li>Cookie store support has been added. The <code>cookie_store</code> option allows configuring the cookie store backend. The <code>gun_cookies</code> module provides functions to help implementing such a backend. Gun comes with the backend <code>gun_cookies_list</code> which provides a per-connection, non-persistent cookie store. The cookie store engine implements the entire RFC6265bis draft algorithms except the parts about non-HTTP cookies as no such interface is provided; and the parts about SameSite as Gun has no concept of &quot;browsing context&quot;.
+</li>
+<li>Graceful shutdown has been implemented. Graceful shutdown can be initiated on the client side by calling the new function <code>gun:shutdown/1</code> or when the owner process goes away; or on the peer side via the connection: close HTTP/1.1 header, the HTTP/2 GOAWAY frame or the Websocket close frame. Gun will try to complete existing streams when possible; other streams get canceled immediately. The <code>closing_timeout</code> option controls how long we are willing to wait at most before closing the connection.
+</li>
+<li>Gun will better detect connection failures by checking the return value from sending data to the socket. This applies to all supported protocols. In addition, Gun now enables <code>send_timeout_close</code> with a <code>send_timeout</code> value defaulting to 15s.
+</li>
+<li>Flow control has been added. It allows limiting the number of data/Websocket messages Gun sends to the calling process. Gun will stop reading from the socket or stop updating the protocol&apos;s flow control window when applicable as well, to apply some backpressure to the remote endpoint(s). It is disabled by default and can be applied on a per-request basis if necessary.
+</li>
+<li>An event handler interface has been added providing access to many internal Gun events. This can be used for a variety of purposes including logging, tracing or otherwise instrumenting a Gun connection.
+</li>
+<li>In order to get separate events when connecting, the domain lookup, connection and TLS handshakes are now performed separately by Gun. As a result, there exists three separate timeout options for each of the steps, and the transport options had to be split into <code>tcp_opts</code> and <code>tls_opts</code>.
+</li>
+<li>Gun now supports connecting through SOCKS proxies, including secure SOCKS proxies. Both unauthenticated and username/password authentication are supported.
+</li>
+<li>Gun can connect through any number of HTTP, HTTPS, SOCKS or secure SOCKS proxies, including SOCKS proxies located after HTTP(S) proxies. The ultimate endpoint may be using any protocol, including plain TCP, TLS, HTTP/1.1 or HTTP/2.
+</li>
+<li>When specifying which protocols to use, options can now be provided specific to those protocols. It is now possible to have separate HTTP options for an HTTP proxy and the origin HTTP server, for example. See the new <code>gun:protocols()</code> type for details.
+</li>
+<li>Gun can now be used to send and receive raw data, as if it was just a normal socket. This can be useful when needing to connect through a number of HTTP/Socks proxies, allowing the use of Gun&apos;s great proxying capabilities (including TLS over TLS) for any sort of protocols. This can also be useful when performing HTTP/1.1 Upgrade to custom protocols.
+</li>
+<li>Headers can now be provided as a map.
+</li>
+<li>Header names may now be provided as binary, string or atom.
+</li>
+<li>Gun now automatically lowercases provided header names.
+</li>
+<li>Many HTTP/2 options have been added, allowing great control over how Gun and the remote endpoint are using the HTTP/2 connection. They can be used to improve performance or lower the memory usage, for example.
+</li>
+<li>A new <code>keepalive_tolerance</code> option for HTTP/2 enables closing the connection automatically when ping acks are not received in a timely manner. It nicely complements the <code>keepalive</code> option that makes Gun send pings.
+</li>
+<li>Gun now supports Websocket subprotocol negotiation and the feature is fully documented and tested. This can be used to create handlers that will implement a protocol from within the Gun process itself. The negotiation is enabled by setting the <code>protocols</code> setting. The <code>default_protocol</code> and <code>user_opts</code> settings are also useful.
+</li>
+<li>It is now possible to send many Websocket frames in a single <code>gun:ws_send/3</code> call.
+</li>
+<li>Gun may now send Websocket ping frames automatically at intervals determined by the <code>keepalive</code> option. It is disabled by default.
+</li>
+<li>A new <code>silence_pings</code> option can be set to <code>false</code> to receive all ping and pong frames when using Websocket. They are typically not needed and therefore silent by default.
+</li>
+<li>The <code>reply_to</code> option has been added to <code>gun:ws_upgrade/4</code>. The option applies to both the response and subsequent Websocket frames.
+</li>
+<li>The <code>reply_to</code> option is also propagated to messages following a CONNECT request when the protocol requested is not HTTP.
+</li>
+<li>A new option <code>retry_fun</code> can be used to implement different backoff strategies when reconnecting.
+</li>
+<li>A new option <code>supervise</code> can be used to start a Gun connection without using Gun&apos;s supervisor. It defaults to <code>true</code>.
+</li>
+<li>Many improvements have been done to postpone or reject requests and other operations while in the wrong state (for example during state transitions when switching protocols or connecting to proxies).
+</li>
+<li>Update Cowlib to 2.12.0.
+</li>
+</ul>
+<h2 id="_experimental_features_added">Experimental features added</h2>
+<ul><li>The <code>gun_pool</code> module was introduced. Its interface is very similar to the <code>gun</code> module, but as it is an experimental feature, it has not been documented yet. The intent is to obtain feedback and document it in an upcoming minor release. Pools are created for each authority (host/port) and scope (user-defined value) pairs and are resolved accordingly using the information provided in the request and request options. Connections may concurrently handle multiple requests/responses from as many different processes as required.
+</li>
+</ul>
+<h2 id="_features_removed">Features removed</h2>
+<ul><li>Gun used to reject operations by processes that were not the owner of the connection. This behavior has been removed. In general the caller of a request or other operation will receive the relevant messages unless the <code>reply_to</code> option is used.
+</li>
+<li>The <code>connect_destination()</code> option <code>protocol</code> has been removed. It was previously deprecated in favor of <code>protocols</code>.
+</li>
+<li>The <code>keepalive</code> timeout is now disabled by default for HTTP/1.1 and HTTP/2. To be perfectly clear, this is unrelated to the HTTP/1.1 keep-alive mechanism.
+</li>
+</ul>
+<h2 id="_functions_added">Functions added</h2>
+<ul><li>The function <code>gun:set_owner/2</code> has been added. It allows changing the owner of a connection process. Only the current owner can do this operation.
+</li>
+<li>The function <code>gun:shutdown/1</code> has been added. It initiates the graceful shutdown of the connection, followed by the termination of the Gun process.
+</li>
+<li>The function <code>gun:stream_info/2</code> has been added. It provides information about a specific HTTP stream.
+</li>
+</ul>
+<h2 id="_functions_modified">Functions modified</h2>
+<ul><li>The function <code>gun:info/1</code> now returns the owner of the connection as well as the cookie store.
+</li>
+<li>The functions <code>gun:await/2,3,4</code>, <code>gun:await_body/2,3,4</code> and <code>gun:await_up/1,2,3</code> now distinguish the error types. They can be a timeout, a connection error, a stream error or a down error (when the Gun process exited while waiting).
+</li>
+<li>The functions <code>gun:await/2,3,4</code> will now receive upgrades, tunnel up and Websocket messages and return them.
+</li>
+<li>Requests may now include the <code>tunnel</code> option to send the request on a specific tunnel.
+</li>
+<li>The functions <code>gun:request/4,5,6</code> have been replaced with <code>gun:headers/4,5</code> and <code>gun:request/5,6</code>. This provides a cleaner separation between requests that are followed by a body and those that aren&apos;t.
+</li>
+<li>The function <code>gun:ws_send/2</code> has been replaced with the function <code>gun:ws_send/3</code>. The stream reference for the corresponding Websocket upgrade request must now be given.
+</li>
+</ul>
+<h2 id="_messages_added">Messages added</h2>
+<ul><li>The <code>gun_tunnel_up</code> message has been added.
+</li>
+</ul>
+<h2 id="_messages_modified">Messages modified</h2>
+<ul><li>The <code>gun_down</code> message no longer has its final element documented as <code>UnprocessedStreams</code>. It never worked and was always an empty list.
+</li>
+</ul>
+<h2 id="_bugs_fixed">Bugs fixed</h2>
+<ul><li><strong>POTENTIAL SECURITY VULNERABILITY</strong>: Fix transfer-encoding precedence over content-length in responses. This bug may contribute to a response smuggling security vulnerability when Gun is used inside a proxy.
+</li>
+<li>Gun will now better detect connection closes in some cases.
+</li>
+<li>Gun will no longer send duplicate connection-wide <code>gun_error</code> messages to the same process.
+</li>
+<li>Gun no longer crashes when trying to upgrade to Websocket over a connection restricted to HTTP/1.0.
+</li>
+<li>The default value for the preferred protocols when using CONNECT over TLS has been corrected. It was mistakenly not enabling HTTP/2.
+</li>
+<li>Protocol options provided for a tunnel destination were sometimes ignored. This should no longer be the case.
+</li>
+<li>Gun will no longer send an empty HTTP/2 DATA frame when there is no request body. It was not necessary.
+</li>
+<li>Gun will no longer error out when the owner process exits. The error reason will now be a <code>shutdown</code> tuple instead.
+</li>
+<li>The host header was set incorrectly during Websocket upgrades when the host was configured with an IP address, resulting in a crash. This has been corrected.
+</li>
+<li>A completed stream could be found in the <code>gun_down</code> message when the response contained a connection: close header. This is no longer the case.
+</li>
+<li>Hostnames can now be provided as atom as stated by the documentation.
+</li>
+<li>Gun will no longer attempt to send empty data chunks. When using HTTP/1.1 chunked transfer-encoding this caused the request body to end, even when <code>nofin</code> was given.
+</li>
+<li>Gun now always retries connecting immediately when the connection goes down.
+</li>
+<li>The default port number for the HTTP and HTTPS schemes is no longer sent in the host header.
+</li>
+<li>An invalid stream reference was sent on failed Websocket upgrade responses. This has been corrected.
+</li>
+<li>HTTP/2 connection preface errors are now properly detected and propagated in the <code>gun_down</code> message to the connection owner as well as the exit reason of the Gun process.
+</li>
+<li>HTTP/2 connection preface errors now provide a different human readable error when the data received looks like an HTTP/1.x response.
+</li>
+<li>HTTP/2 connection errors were missing the human readable reason in the <code>gun_error</code> message. This has been corrected.
+</li>
+<li>Fix the host and :authority (pseudo-)headers when connecting to an IPv6 address given as a tuple. They were lacking the surrounding brackets.
+</li>
+<li>Fix a crash in gun:info/1 when the socket was closed before we call Transport:sockname/1.
+</li>
+<li>Fix flushing by stream reference. When the <code>gun_inform</code> message was flushed the function would switch to flushing all messages from the pid instead of only messages from the given stream.
+</li>
+<li>Allow setting a custom SNI value.
+</li>
+<li>Fix double sending of last chunk in HTTP/1.1 when Gun is asked to send empty data before closing the stream.
+</li>
+<li>Gun will now properly ignore parameters when the media type is text/event-stream.
+</li>
+<li>Avoid noisy crashes in the TLS over TLS code.
+</li>
+<li>Gun will now include the StreamRef of Websocket streams when sending <code>gun_down</code> messages.
+</li>
+<li>Gun will no longer reject HTTP proxies that use HTTP/1.0 for the version in their response.
+</li>
+</ul>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/migrating_from_2.0/">
+ Migrating from Gun 2.0 to 2.1
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/migrating_from_1.2/">
+ Migrating from Gun 1.2 to 1.3
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/migrating_from_2.0.asciidoc b/docs/en/gun/2.1/guide/migrating_from_2.0.asciidoc
new file mode 100644
index 00000000..cfd64a8d
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_2.0.asciidoc
@@ -0,0 +1,25 @@
+[appendix]
+== Migrating from Gun 2.0 to 2.1
+
+Gun 2.1 contains a small security improvement for
+the HTTP/2 protocol, as well as includes a small
+number of fixes and improvements.
+
+Gun 2.1 requires Erlang/OTP 22.0 or greater.
+
+=== Features added
+
+* A new HTTP/2 option `max_fragmented_header_block_size` has
+ been added to limit the size of header blocks that are
+ sent over multiple HEADERS and CONTINUATION frames.
+
+* Update Cowlib to 2.13.0.
+
+=== Bugs fixed
+
+* Gun will no longer configure the NPN TLS extension,
+ which has long been replaced by ALPN. NPN is not
+ compatible with TLS 1.3.
+
+* Gun will no longer crash when TLS connections close
+ very early in the connection's life time.
diff --git a/docs/en/gun/2.1/guide/migrating_from_2.0/index.html b/docs/en/gun/2.1/guide/migrating_from_2.0/index.html
new file mode 100644
index 00000000..b2883c28
--- /dev/null
+++ b/docs/en/gun/2.1/guide/migrating_from_2.0/index.html
@@ -0,0 +1,194 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Migrating from Gun 2.0 to 2.1</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Migrating from Gun 2.0 to 2.1</span></h1>
+
+<p>Gun 2.1 contains a small security improvement for the HTTP/2 protocol, as well as includes a small number of fixes and improvements.</p>
+<p>Gun 2.1 requires Erlang/OTP 22.0 or greater.</p>
+<h2 id="_features_added">Features added</h2>
+<ul><li>A new HTTP/2 option <code>max_fragmented_header_block_size</code> has been added to limit the size of header blocks that are sent over multiple HEADERS and CONTINUATION frames.
+</li>
+<li>Update Cowlib to 2.13.0.
+</li>
+</ul>
+<h2 id="_bugs_fixed">Bugs fixed</h2>
+<ul><li>Gun will no longer configure the NPN TLS extension, which has long been replaced by ALPN. NPN is not compatible with TLS 1.3.
+</li>
+<li>Gun will no longer crash when TLS connections close very early in the connection&apos;s life time.
+</li>
+</ul>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/internals_tls_over_tls/">
+ Internals: TLS over TLS
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/migrating_from_1.3/">
+ Migrating from Gun 1.3 to 2.0
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/protocols.asciidoc b/docs/en/gun/2.1/guide/protocols.asciidoc
new file mode 100644
index 00000000..cd6de2cf
--- /dev/null
+++ b/docs/en/gun/2.1/guide/protocols.asciidoc
@@ -0,0 +1,120 @@
+[[protocols]]
+== Supported protocols
+
+This chapter describes the protocols supported and the
+operations available to them.
+
+=== HTTP/1.1
+
+HTTP/1.1 is a text request-response protocol. The client
+sends a request, the server sends back a response.
+
+Gun provides convenience functions for performing GET, HEAD,
+OPTIONS, POST, PATCH, PUT, and DELETE requests. All these
+functions are aliases of `gun:headers/4,5` or `gun:request/5,6`
+for the respective methods. Gun also provides a `gun:data/4`
+function for streaming the request body.
+
+Gun will send a `gun_inform` message for every intermediate
+informational responses received. They will always be sent
+before the `gun_response` message.
+
+Gun will send a `gun_response` message for every response
+received, followed by zero or more `gun_data` messages for
+the response body, which is optionally terminated by a
+`gun_trailers` message. If something goes wrong, a `gun_error`
+will be sent instead.
+
+Gun provides convenience functions for dealing with messages.
+The `gun:await/2,3,4` function waits for a response to the given
+request, and the `gun:await_body/2,3,4` function for the
+response body. The `gun:flush/1` function can be used to clear all
+messages related to a request or a connection from the mailbox
+of the calling process.
+
+The function `gun:cancel/2` 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 responses can be received.
+
+Finally, Gun can upgrade an HTTP/1.1 connection to Websocket.
+It provides the `gun:ws_upgrade/2,3,4` function for that
+purpose. A `gun_upgrade` message will be sent on success;
+a `gun_response` message otherwise.
+
+=== HTTP/2
+
+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 additional resources along with
+the normal response to the original request.
+
+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.
+
+Gun will send `gun_push` messages for every push received.
+They will always be sent before the `gun_response` message.
+They can be ignored safely if they are not needed, or they
+can be canceled.
+
+The `gun:cancel/2` 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.
+
+=== Websocket
+
+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.
+
+Once the Websocket connection is established over an HTTP/1.1
+connection, the only operation available on this connection
+is sending Websocket frames using `gun:ws_send/3`.
+
+Gun will send a `gun_ws` message for every frame received.
+
+=== Summary
+
+The two following tables summarize the supported operations
+and the messages Gun sends depending on the connection's
+current protocol.
+
+.Supported operations per protocol
+[cols="<,3*^",options="header"]
+|===
+| Operation | HTTP/1.1 | HTTP/2 | Websocket
+| delete | yes | yes | no
+| get | yes | yes | no
+| head | yes | yes | no
+| options | yes | yes | no
+| patch | yes | yes | no
+| post | yes | yes | no
+| put | yes | yes | no
+| request | yes | yes | no
+| data | yes | yes | no
+| await | yes | yes | no
+| await_body | yes | yes | no
+| flush | yes | yes | no
+| cancel | yes | yes | no
+| ws_upgrade | yes | yes | no
+| ws_send | no | no | yes
+|===
+
+.Messages sent per protocol
+[cols="<,3*^",options="header"]
+|===
+| Message | HTTP/1.1 | HTTP/2 | Websocket
+| gun_push | no | yes | no
+| gun_inform | yes | yes | no
+| gun_response | yes | yes | no
+| gun_data | yes | yes | no
+| gun_trailers | yes | yes | no
+| gun_error | yes | yes | yes
+| gun_upgrade | yes | yes | no
+| gun_ws | no | no | yes
+|===
diff --git a/docs/en/gun/2.1/guide/protocols/index.html b/docs/en/gun/2.1/guide/protocols/index.html
new file mode 100644
index 00000000..c0fb3a8a
--- /dev/null
+++ b/docs/en/gun/2.1/guide/protocols/index.html
@@ -0,0 +1,329 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Supported protocols</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Supported protocols</span></h1>
+
+<p>This chapter describes the protocols supported and the operations available to them.</p>
+<h2 id="_http_1_1">HTTP/1.1</h2>
+<p>HTTP/1.1 is a text request-response protocol. The client sends a request, the server sends back a response.</p>
+<p>Gun provides convenience functions for performing GET, HEAD, OPTIONS, POST, PATCH, PUT, and DELETE requests. All these functions are aliases of <code>gun:headers/4,5</code> or <code>gun:request/5,6</code> for the respective methods. Gun also provides a <code>gun:data/4</code> function for streaming the request body.</p>
+<p>Gun will send a <code>gun_inform</code> message for every intermediate informational responses received. They will always be sent before the <code>gun_response</code> message.</p>
+<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, which is optionally terminated by a <code>gun_trailers</code> message. If something goes wrong, a <code>gun_error</code> will be sent instead.</p>
+<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 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 calling process.</p>
+<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 responses can be received.</p>
+<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_upgrade</code> message will be sent on success; a <code>gun_response</code> message otherwise.</p>
+<h2 id="_http_2">HTTP/2</h2>
+<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 additional resources along with the normal response to the original request.</p>
+<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>
+<p>Gun will send <code>gun_push</code> messages for every push received. They will always be sent before the <code>gun_response</code> message. They can be ignored safely if they are not needed, or they can be canceled.</p>
+<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>
+<h2 id="_websocket">Websocket</h2>
+<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>
+<p>Once the Websocket connection is established over an HTTP/1.1 connection, the only operation available on this connection is sending Websocket frames using <code>gun:ws_send/3</code>.</p>
+<p>Gun will send a <code>gun_ws</code> message for every frame received.</p>
+<h2 id="_summary">Summary</h2>
+<p>The two following tables summarize the supported operations and the messages Gun sends depending on the connection&apos;s current protocol.</p>
+<table rules="all" width="100%" frame="border"
+ cellspacing="0" cellpadding="4">
+<caption>Supported operations per protocol</caption><thead><tr><th>Operation</th>
+<th>HTTP/1.1</th>
+<th>HTTP/2</th>
+<th>Websocket</th>
+</tr></thead><tbody><tr><td>delete</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>get</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>head</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>options</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>patch</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>post</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>put</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>request</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>data</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>await</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>await_body</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>flush</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>cancel</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>ws_upgrade</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>ws_send</td>
+<td>no</td>
+<td>no</td>
+<td>yes</td>
+</tr>
+</tbody></table>
+<table rules="all" width="100%" frame="border"
+ cellspacing="0" cellpadding="4">
+<caption>Messages sent per protocol</caption><thead><tr><th>Message</th>
+<th>HTTP/1.1</th>
+<th>HTTP/2</th>
+<th>Websocket</th>
+</tr></thead><tbody><tr><td>gun_push</td>
+<td>no</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>gun_inform</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>gun_response</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>gun_data</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>gun_trailers</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>gun_error</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+</tr>
+<tr><td>gun_upgrade</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr><td>gun_ws</td>
+<td>no</td>
+<td>no</td>
+<td>yes</td>
+</tr>
+</tbody></table>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/start/">
+ Starting and stopping
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/connect/">
+ Connection
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/start.asciidoc b/docs/en/gun/2.1/guide/start.asciidoc
new file mode 100644
index 00000000..09720dca
--- /dev/null
+++ b/docs/en/gun/2.1/guide/start.asciidoc
@@ -0,0 +1,43 @@
+[[start]]
+== Starting and stopping
+
+This chapter describes how to start and stop the Gun application.
+
+=== Setting up
+
+Specify Gun as a dependency to your application in your favorite
+build tool.
+
+With Erlang.mk this is done by adding `gun` to the `DEPS` variable
+in your Makefile.
+
+.Adding Gun as an Erlang.mk dependency
+[source,make]
+----
+DEPS = gun
+----
+
+=== Starting
+
+Gun is an _OTP application_. It needs to be started before you can
+use it.
+
+.Starting Gun in an Erlang shell
+[source,erlang]
+----
+1> application:ensure_all_started(gun).
+{ok,[crypto,cowlib,asn1,public_key,ssl,gun]}
+----
+
+=== Stopping
+
+You can stop Gun using the `application:stop/1` function, however
+only Gun will be stopped. This is the reverse of `application:start/1`.
+The `application_ensure_all_started/1` function has no equivalent for
+stopping all applications.
+
+.Stopping Gun
+[source,erlang]
+----
+application:stop(gun).
+----
diff --git a/docs/en/gun/2.1/guide/start/index.html b/docs/en/gun/2.1/guide/start/index.html
new file mode 100644
index 00000000..44e538b1
--- /dev/null
+++ b/docs/en/gun/2.1/guide/start/index.html
@@ -0,0 +1,206 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Starting and stopping</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Starting and stopping</span></h1>
+
+<p>This chapter describes how to start and stop the Gun application.</p>
+<h2 id="_setting_up">Setting up</h2>
+<p>Specify Gun as a dependency to your application in your favorite build tool.</p>
+<p>With Erlang.mk this is done by adding <code>gun</code> to the <code>DEPS</code> variable in your Makefile.</p>
+<div class="listingblock"><div class="title">Adding Gun as an Erlang.mk dependency</div>
+<div class="content">source-highlight: could not find a language definition for make
+</div></div>
+<h2 id="_starting">Starting</h2>
+<p>Gun is an <em>OTP application</em>. It needs to be started before you can use it.</p>
+<div class="listingblock"><div class="title">Starting Gun in an Erlang shell</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#993399">1</font><font color="#990000">&gt;</font> <b><font color="#000000">application:ensure_all_started</font></b>(<font color="#FF6600">gun</font>)<font color="#990000">.</font>
+{<font color="#FF6600">ok</font>,[<font color="#FF6600">crypto</font>,<font color="#FF6600">cowlib</font>,<font color="#FF6600">asn1</font>,<font color="#FF6600">public_key</font>,<font color="#FF6600">ssl</font>,<font color="#FF6600">gun</font>]}</tt></pre>
+</div></div>
+<h2 id="_stopping">Stopping</h2>
+<p>You can stop Gun using the <code>application:stop/1</code> function, however only Gun will be stopped. This is the reverse of <code>application:start/1</code>. The <code>application_ensure_all_started/1</code> function has no equivalent for stopping all applications.</p>
+<div class="listingblock"><div class="title">Stopping Gun</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">application:stop</font></b>(<font color="#FF6600">gun</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/introduction/">
+ Introduction
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/protocols/">
+ Supported protocols
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+
diff --git a/docs/en/gun/2.1/guide/websocket.asciidoc b/docs/en/gun/2.1/guide/websocket.asciidoc
new file mode 100644
index 00000000..ba06e2c7
--- /dev/null
+++ b/docs/en/gun/2.1/guide/websocket.asciidoc
@@ -0,0 +1,124 @@
+[[websocket]]
+== Websocket
+
+This chapter describes how to use the Gun client for
+communicating with a Websocket server.
+
+// @todo recovering from connection failure, reconnecting to Websocket etc.
+
+=== HTTP upgrade
+
+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.
+
+You must use the `gun:ws_upgrade/2,3,4` function to upgrade
+to Websocket. This function can be called anytime after connection,
+so you can send HTTP requests before upgrading to Websocket.
+
+.Upgrade to Websocket
+[source,erlang]
+----
+gun:ws_upgrade(ConnPid, "/websocket").
+----
+
+Gun will set all the necessary headers for performing the
+Websocket upgrade, but you can specify additional headers
+if needed. For example you can authenticate.
+
+.Upgrade to Websocket using HTTP authentication
+[source,erlang]
+----
+gun:ws_upgrade(ConnPid, "/websocket", [
+ {<<"authorization">>, "Basic dXNlcm5hbWU6cGFzc3dvcmQ="}
+]).
+----
+
+You can pass the Websocket options as part of the `gun:open/2,3`
+call when opening the connection, or using the `gun:ws_upgrade/4`.
+The fourth argument is those same options.
+
+Gun can negotiate the protocol to be used for the Websocket
+connection. The `protocols` option can be given with a list
+of protocols accepted and the corresponding handler module.
+Note that the interface for handler modules is currently
+undocumented and must be set to `gun_ws_h`.
+
+.Upgrade to Websocket with protocol negotiation
+[source,erlang]
+----
+StreamRef = gun:ws_upgrade(ConnPid, "/websocket", []
+ #{protocols => [{<<"xmpp">>, gun_ws_h}]}).
+----
+
+The upgrade will fail if the server cannot satisfy the
+protocol negotiation.
+
+When the upgrade succeeds, a `gun_upgrade` message is sent.
+If the server does not understand Websocket or refused the
+upgrade, a `gun_response` message is sent. If Gun couldn't
+perform the upgrade due to an error (for example attempting
+to upgrade to Websocket on an HTTP/1.0 connection) then a
+`gun_error` message is sent.
+
+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:
+
+[source,erlang]
+----
+receive
+ {gun_upgrade, ConnPid, StreamRef, [<<"websocket">>], Headers} ->
+ upgrade_success(ConnPid, StreamRef);
+ {gun_response, ConnPid, _, _, Status, Headers} ->
+ exit({ws_upgrade_failed, Status, Headers});
+ {gun_error, ConnPid, StreamRef, Reason} ->
+ exit({ws_upgrade_failed, Reason})
+ %% More clauses here as needed.
+after 1000 ->
+ exit(timeout)
+end.
+----
+
+=== Sending data
+
+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.
+
+Use `gun:ws_send/3` to send messages to the server.
+
+.Send a text frame
+[source,erlang]
+----
+gun:ws_send(ConnPid, StreamRef, {text, "Hello!"}).
+----
+
+.Send a text frame, a binary frame and then close the connection
+[source,erlang]
+----
+gun:ws_send(ConnPid, StreamRef, [
+ {text, "Hello!"},
+ {binary, BinaryValue},
+ close
+]).
+----
+
+Note that if you send a close frame, Gun will close the connection
+cleanly but may attempt to reconnect afterwards depending on the
+`retry` configuration.
+
+=== Receiving data
+
+Gun sends an Erlang message to the owner process for every
+Websocket message it receives.
+
+[source,erlang]
+----
+receive
+ {gun_ws, ConnPid, StreamRef, Frame} ->
+ handle_frame(ConnPid, StreamRef, Frame)
+end.
+----
diff --git a/docs/en/gun/2.1/guide/websocket/index.html b/docs/en/gun/2.1/guide/websocket/index.html
new file mode 100644
index 00000000..cf154726
--- /dev/null
+++ b/docs/en/gun/2.1/guide/websocket/index.html
@@ -0,0 +1,264 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: Websocket</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>Websocket</span></h1>
+
+<p>This chapter describes how to use the Gun client for communicating with a Websocket server.</p>
+<!-- @todo recovering from connection failure, reconnecting to Websocket etc.-->
+<h2 id="_http_upgrade">HTTP upgrade</h2>
+<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>
+<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 class="listingblock"><div class="title">Upgrade to Websocket</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">gun:ws_upgrade</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/websocket"</font>)<font color="#990000">.</font></tt></pre>
+</div></div>
+<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 authenticate.</p>
+<div class="listingblock"><div class="title">Upgrade to Websocket using HTTP authentication</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">gun:ws_upgrade</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/websocket"</font>, [
+ {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"authorization"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF0000">"Basic dXNlcm5hbWU6cGFzc3dvcmQ="</font>}
+])<font color="#990000">.</font></tt></pre>
+</div></div>
+<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.</p>
+<p>Gun can negotiate the protocol to be used for the Websocket connection. The <code>protocols</code> option can be given with a list of protocols accepted and the corresponding handler module. Note that the interface for handler modules is currently undocumented and must be set to <code>gun_ws_h</code>.</p>
+<div class="listingblock"><div class="title">Upgrade to Websocket with protocol negotiation</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">StreamRef</font> <font color="#990000">=</font> <b><font color="#000000">gun:ws_upgrade</font></b>(<font color="#009900">ConnPid</font>, <font color="#FF0000">"/websocket"</font>, []
+ #{<font color="#0000FF">protocols</font> <font color="#990000">=&gt;</font> [{<font color="#990000">&lt;&lt;</font><font color="#FF0000">"xmpp"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF6600">gun_ws_h</font>}]})<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>The upgrade will fail if the server cannot satisfy the protocol negotiation.</p>
+<p>When the upgrade succeeds, a <code>gun_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&apos;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>
+<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 class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#0000FF">receive</font></b>
+ {<font color="#FF6600">gun_upgrade</font>, <font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, [<font color="#990000">&lt;&lt;</font><font color="#FF0000">"websocket"</font><font color="#990000">&gt;&gt;</font>], <font color="#009900">Headers</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">upgrade_success</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>);
+ {<font color="#FF6600">gun_response</font>, <font color="#009900">ConnPid</font>, <font color="#990000">_</font>, <font color="#990000">_</font>, <font color="#009900">Status</font>, <font color="#009900">Headers</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000080">exit</font></b>({<font color="#FF6600">ws_upgrade_failed</font>, <font color="#009900">Status</font>, <font color="#009900">Headers</font>});
+ {<font color="#FF6600">gun_error</font>, <font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#009900">Reason</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000080">exit</font></b>({<font color="#FF6600">ws_upgrade_failed</font>, <font color="#009900">Reason</font>})
+ <i><font color="#9A1900">%% More clauses here as needed.</font></i>
+<b><font color="#0000FF">after</font></b> <font color="#993399">1000</font> <font color="#990000">-&gt;</font>
+ <b><font color="#000080">exit</font></b>(<font color="#FF6600">timeout</font>)
+<b><font color="#0000FF">end</font></b><font color="#990000">.</font></tt></pre>
+</div></div>
+<h2 id="_sending_data">Sending data</h2>
+<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>
+<p>Use <code>gun:ws_send/3</code> to send messages to the server.</p>
+<div class="listingblock"><div class="title">Send a text frame</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">gun:ws_send</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, {<font color="#FF6600">text</font>, <font color="#FF0000">"Hello!"</font>})<font color="#990000">.</font></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.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">gun:ws_send</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, [
+ {<font color="#FF6600">text</font>, <font color="#FF0000">"Hello!"</font>},
+ {<b><font color="#000080">binary</font></b>, <font color="#009900">BinaryValue</font>},
+ <font color="#FF6600">close</font>
+])<font color="#990000">.</font></tt></pre>
+</div></div>
+<p>Note that if you send a close frame, Gun will close the connection cleanly but may attempt to reconnect afterwards depending on the <code>retry</code> configuration.</p>
+<h2 id="_receiving_data">Receiving data</h2>
+<p>Gun sends an Erlang message to the owner process for every Websocket message it receives.</p>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#0000FF">receive</font></b>
+ {<font color="#FF6600">gun_ws</font>, <font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#009900">Frame</font>} <font color="#990000">-&gt;</font>
+ <b><font color="#000000">handle_frame</font></b>(<font color="#009900">ConnPid</font>, <font color="#009900">StreamRef</font>, <font color="#009900">Frame</font>)
+<b><font color="#0000FF">end</font></b><font color="#990000">.</font></tt></pre>
+</div></div>
+
+
+
+
+
+
+
+
+
+
+
+ <nav style="margin:1em 0">
+
+ <a style="float:left" href="https://ninenines.eu/docs/en/gun/2.1/guide/http/">
+ HTTP
+ </a>
+
+
+
+ <a style="float:right" href="https://ninenines.eu/docs/en/gun/2.1/guide/internals_tls_over_tls/">
+ Internals: TLS over TLS
+ </a>
+
+ </nav>
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Gun
+ 2.1
+
+ User Guide
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/gun/2.1/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/gun/2.1/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/gun/2.1/guide">2.1</a></li>
+
+ <li><a href="/docs/en/gun/2.0/guide">2.0</a></li>
+
+ <li><a href="/docs/en/gun/1.3/guide">1.3</a></li>
+
+ <li><a href="/docs/en/gun/1.2/guide">1.2</a></li>
+
+ <li><a href="/docs/en/gun/1.1/guide">1.1</a></li>
+
+ <li><a href="/docs/en/gun/1.0/guide">1.0</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+