summaryrefslogtreecommitdiffstats
path: root/docs/en/cowboy/2.2/manual/cowboy_stream/index.html
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-12-11 11:27:17 +0100
committerLoïc Hoguin <[email protected]>2017-12-11 11:27:17 +0100
commit1b863c350ba1f9b8ad1cb458df514ab0fe6bb127 (patch)
treef3f88acba06cce7095a047da8163ac0f92b1a64a /docs/en/cowboy/2.2/manual/cowboy_stream/index.html
parent35825f89b61579d4270d6970609047945277acf7 (diff)
downloadninenines.eu-1b863c350ba1f9b8ad1cb458df514ab0fe6bb127.tar.gz
ninenines.eu-1b863c350ba1f9b8ad1cb458df514ab0fe6bb127.tar.bz2
ninenines.eu-1b863c350ba1f9b8ad1cb458df514ab0fe6bb127.zip
Add documentation for Cowboy 2.2
Diffstat (limited to 'docs/en/cowboy/2.2/manual/cowboy_stream/index.html')
-rw-r--r--docs/en/cowboy/2.2/manual/cowboy_stream/index.html564
1 files changed, 564 insertions, 0 deletions
diff --git a/docs/en/cowboy/2.2/manual/cowboy_stream/index.html b/docs/en/cowboy/2.2/manual/cowboy_stream/index.html
new file mode 100644
index 00000000..1a565ef0
--- /dev/null
+++ b/docs/en/cowboy/2.2/manual/cowboy_stream/index.html
@@ -0,0 +1,564 @@
+<!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">
+
+ <meta name="generator" content="Hugo 0.30.2" />
+
+ <title>Nine Nines: cowboy_stream(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=1" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>cowboy_stream(3)</span></h1>
+
+<div class="sect1">
+<h2 id="_name">Name</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>cowboy_handler - Stream handlers</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_description">Description</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The module <code>cowboy_stream</code> defines a callback interface
+and a protocol for handling HTTP streams.</p></div>
+<div class="paragraph"><p>An HTTP request and its associated response is called
+a stream. A connection may have many streams. In HTTP/1.1
+they are executed sequentially, while in HTTP/2 they are
+executed concurrently.</p></div>
+<div class="paragraph"><p>Cowboy calls the stream handler for nearly all events
+related to a stream. Exceptions vary depending on the
+protocol.</p></div>
+<div class="paragraph"><p>Extra care must be taken when implementing stream handlers
+to ensure compatibility. While some modification of the
+events and commands is allowed, it is generally not a good
+idea to completely omit them.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_callbacks">Callbacks</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Stream handlers must implement the following interface:</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">init</span></span>(<span style="color: #009900">StreamID</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">Opts</span>) <span style="color: #990000">-&gt;</span> {<span style="color: #009900">Commands</span>, <span style="color: #009900">State</span>}
+<span style="font-weight: bold"><span style="color: #000000">data</span></span>(<span style="color: #009900">StreamID</span>, <span style="color: #009900">IsFin</span>, <span style="color: #009900">Data</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-&gt;</span> {<span style="color: #009900">Commands</span>, <span style="color: #009900">State</span>}
+<span style="font-weight: bold"><span style="color: #000000">info</span></span>(<span style="color: #009900">StreamID</span>, <span style="color: #009900">Info</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-&gt;</span> {<span style="color: #009900">Commands</span>, <span style="color: #009900">State</span>}
+<span style="font-weight: bold"><span style="color: #000000">terminate</span></span>(<span style="color: #009900">StreamID</span>, <span style="color: #009900">Reason</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">any</span></span>()
+<span style="font-weight: bold"><span style="color: #000000">early_error</span></span>(<span style="color: #009900">StreamID</span>, <span style="color: #009900">Reason</span>, <span style="color: #009900">PartialReq</span>, <span style="color: #009900">Resp</span>, <span style="color: #009900">Opts</span>) <span style="color: #990000">-&gt;</span> <span style="color: #009900">Resp</span>
+
+<span style="color: #009900">StreamID</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_stream:streamid</span></span>()
+<span style="color: #009900">Req</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:req</span></span>()
+<span style="color: #009900">Opts</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy:opts</span></span>()
+<span style="color: #009900">Commands</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_stream:commands</span></span>()
+<span style="color: #009900">State</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">any</span></span>()
+<span style="color: #009900">IsFin</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_stream:fin</span></span>()
+<span style="color: #009900">Data</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000080">binary</span></span>()
+<span style="color: #009900">Info</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">any</span></span>()
+<span style="color: #009900">Reason</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_stream:reason</span></span>()
+<span style="color: #009900">PartialReq</span> <span style="color: #990000">-</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:req</span></span>(), <span style="color: #FF6600">except</span> <span style="color: #FF6600">all</span> <span style="color: #FF6600">fields</span> <span style="color: #FF6600">are</span> <span style="color: #FF6600">optional</span>
+<span style="color: #009900">Resp</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_stream:resp_command</span></span>()</tt></pre></div></div>
+<div class="paragraph"><p>HTTP/1.1 will initialize a stream only when the request-line
+and all headers have been received. When errors occur before
+that point Cowboy will call the callback <code>early_error/5</code>
+with a partial request, the error reason and the response
+Cowboy intends to send. All other events go throuh the
+stream handler using the normal callbacks.</p></div>
+<div class="paragraph"><p>HTTP/2 will initialize the stream when the <code>HEADERS</code> block has
+been fully received and decoded. Any protocol error occuring
+before that will not result in a response being sent and
+will therefore not go through the stream handler. In addition
+Cowboy may terminate streams without sending an HTTP response
+back.</p></div>
+<div class="paragraph"><p>The stream is initialized by calling <code>init/3</code>. All streams
+that are initialized will eventually be terminated by calling
+<code>terminate/3</code>.</p></div>
+<div class="paragraph"><p>When Cowboy receives data for the stream it will call <code>data/4</code>.
+The data given is the request body after any transfer decoding
+has been applied.</p></div>
+<div class="paragraph"><p>When Cowboy receives a message addressed to a stream, or when
+Cowboy needs to inform the stream handler that an internal
+event has occurred, it will call <code>info/3</code>.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="commands">Commands</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Stream handlers can return a list of commands to be executed
+from the <code>init/3</code>, <code>data/4</code> and <code>info/3</code> callbacks. In addition,
+the <code>early_error/5</code> callback must return a response command.</p></div>
+<div class="paragraph"><p>The following commands are defined:</p></div>
+<div class="sect2">
+<h3 id="response_command">response</h3>
+<div class="paragraph"><p>Send a response to the client.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">response</span>, <span style="font-weight: bold"><span style="color: #000000">cowboy:http_status</span></span>(), <span style="font-weight: bold"><span style="color: #000000">cowboy:http_headers</span></span>(),
+ <span style="font-weight: bold"><span style="color: #000000">cowboy_req:resp_body</span></span>()}</tt></pre></div></div>
+<div class="paragraph"><p>No more data can be sent after this command.</p></div>
+</div>
+<div class="sect2">
+<h3 id="headers_command">headers</h3>
+<div class="paragraph"><p>Initiate a response to the client.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">headers</span>, <span style="font-weight: bold"><span style="color: #000000">cowboy:http_status</span></span>(), <span style="font-weight: bold"><span style="color: #000000">cowboy:http_headers</span></span>()}</tt></pre></div></div>
+<div class="paragraph"><p>This initiates a response to the client. The stream
+will end when a data command with the <code>fin</code> flag or
+a trailer command is returned.</p></div>
+</div>
+<div class="sect2">
+<h3 id="data_command">data</h3>
+<div class="paragraph"><p>Send data to the client.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">data</span>, <span style="font-weight: bold"><span style="color: #000000">fin</span></span>(), <span style="font-weight: bold"><span style="color: #000000">iodata</span></span>()}</tt></pre></div></div>
+</div>
+<div class="sect2">
+<h3 id="trailers_command">trailers</h3>
+<div class="paragraph"><p>Send response trailers to the client.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">trailers</span>, <span style="font-weight: bold"><span style="color: #000000">cowboy:http_headers</span></span>()}</tt></pre></div></div>
+</div>
+<div class="sect2">
+<h3 id="push_command">push</h3>
+<div class="paragraph"><p>Push a resource to the client.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">push</span>, <span style="color: #009900">Method</span>, <span style="color: #009900">Scheme</span>, <span style="color: #009900">Host</span>, <span style="font-weight: bold"><span style="color: #000000">inet:port_number</span></span>(),
+ <span style="color: #009900">Path</span>, <span style="color: #009900">Qs</span>, <span style="font-weight: bold"><span style="color: #000000">cowboy:http_headers</span></span>()}
+
+<span style="color: #009900">Method</span> <span style="color: #990000">=</span> <span style="color: #009900">Scheme</span> <span style="color: #990000">=</span> <span style="color: #009900">Host</span> <span style="color: #990000">=</span> <span style="color: #009900">Path</span> <span style="color: #990000">=</span> <span style="color: #009900">Qs</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000080">binary</span></span>()</tt></pre></div></div>
+<div class="paragraph"><p>The command will be ignored if the protocol does not provide
+any server push mechanism.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_flow">flow</h3>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">flow</span>, <span style="font-weight: bold"><span style="color: #000000">pos_integer</span></span>()}</tt></pre></div></div>
+<div class="paragraph"><p>Request more data to be read from the request body. The
+exact behavior depends on the protocol.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_spawn">spawn</h3>
+<div class="paragraph"><p>Inform Cowboy that a process was spawned and should be
+supervised.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="font-weight: bold"><span style="color: #000080">spawn</span></span>, <span style="font-weight: bold"><span style="color: #000080">pid</span></span>(), <span style="font-weight: bold"><span style="color: #000000">timeout</span></span>()}</tt></pre></div></div>
+</div>
+<div class="sect2">
+<h3 id="_error_response">error_response</h3>
+<div class="paragraph"><p>Send an error response if no response was sent previously.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">error_response</span>, <span style="font-weight: bold"><span style="color: #000000">cowboy:http_status</span></span>(), <span style="font-weight: bold"><span style="color: #000000">cowboy:http_headers</span></span>(), <span style="font-weight: bold"><span style="color: #000000">iodata</span></span>()}</tt></pre></div></div>
+</div>
+<div class="sect2">
+<h3 id="switch_protocol_command">switch_protocol</h3>
+<div class="paragraph"><p>Switch to a different protocol.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">switch_protocol</span>, <span style="font-weight: bold"><span style="color: #000000">cowboy:http_headers</span></span>(), <span style="font-weight: bold"><span style="color: #000000">module</span></span>(), <span style="font-weight: bold"><span style="color: #000000">state</span></span>()}</tt></pre></div></div>
+<div class="paragraph"><p>Contains the headers that will be sent in the 101 response,
+along with the module implementing the protocol we are
+switching to and its initial state.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_stop">stop</h3>
+<div class="paragraph"><p>Stop the stream.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #FF6600">stop</span></tt></pre></div></div>
+<div class="paragraph"><p>While no more data can be sent after the <code>fin</code> flag was set,
+the stream is still tracked by Cowboy until it is stopped by
+the handler.</p></div>
+<div class="paragraph"><p>The behavior when stopping a stream for which no response
+has been sent will vary depending on the protocol. The stream
+will end successfully as far as the client is concerned.</p></div>
+<div class="paragraph"><p>To indicate that an error occurred, either use <code>error_response</code>
+before stopping, or use <code>internal_error</code>.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_internal_error">internal_error</h3>
+<div class="paragraph"><p>Stop the stream with an error.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #FF6600">internal_error</span>, <span style="color: #009900">Reason</span>, <span style="color: #009900">HumanReadable</span>}
+
+<span style="color: #009900">Reason</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">any</span></span>()
+<span style="color: #009900">HumanReadable</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000080">atom</span></span>()</tt></pre></div></div>
+<div class="paragraph"><p>This command should be used when the stream cannot continue
+because of an internal error. An <code>error_response</code> command
+may be sent before that to advertise to the client why the
+stream is dropped.</p></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_predefined_events">Predefined events</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy will forward all messages sent to the stream to
+the <code>info/3</code> callback. To send a message to a stream,
+send a message to the connection process with the form
+<code>{{Pid, StreamID}, Msg}</code>. The connection process will
+then forward <code>Msg</code> to the stream handlers.</p></div>
+<div class="paragraph"><p>Cowboy will also forward the exit signals for the
+processes that the stream spawned.</p></div>
+<div class="sect2">
+<h3 id="_exit">EXIT</h3>
+<div class="paragraph"><p>A process spawned by this stream has exited.</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>{<span style="color: #000080">'EXIT'</span>, <span style="font-weight: bold"><span style="color: #000080">pid</span></span>(), <span style="font-weight: bold"><span style="color: #000000">any</span></span>()}</tt></pre></div></div>
+<div class="paragraph"><p>This is the raw exit message without any modification.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_response">response</h3>
+<div class="paragraph"><p>Same as the <a href="../response_command">response command</a>.</p></div>
+<div class="paragraph"><p>Usually sent when the request process replies to the client.
+May also be sent by Cowboy internally.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_headers">headers</h3>
+<div class="paragraph"><p>Same as the <a href="../headers_command">headers command</a>.</p></div>
+<div class="paragraph"><p>Sent when the request process starts replying to the client.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_data">data</h3>
+<div class="paragraph"><p>Same as the <a href="../data_command">data command</a>.</p></div>
+<div class="paragraph"><p>Sent when the request process streams data to the client.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_trailers">trailers</h3>
+<div class="paragraph"><p>Same as the <a href="../trailers_command">trailers command</a>.</p></div>
+<div class="paragraph"><p>Sent when the request process sends the trailer field values
+to the client.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_push">push</h3>
+<div class="paragraph"><p>Same as the <a href="../push_command">push command</a>.</p></div>
+<div class="paragraph"><p>Sent when the request process pushes a resource to the client.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_switch_protocol">switch_protocol</h3>
+<div class="paragraph"><p>Same as the <a href="../switch_protocol_command">switch_protocol command</a>.</p></div>
+<div class="paragraph"><p>Sent when switching to the HTTP/2 or Websocket protocol.</p></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_exports">Exports</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The following function should be called by modules implementing
+stream handlers to execute the next stream handler in the list:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="../cowboy_stream.init">cowboy_stream:init(3)</a> - Initialize a stream
+</p>
+</li>
+<li>
+<p>
+<a href="../cowboy_stream.data">cowboy_stream:data(3)</a> - Handle data for a stream
+</p>
+</li>
+<li>
+<p>
+<a href="../cowboy_stream.info">cowboy_stream:info(3)</a> - Handle a message for a stream
+</p>
+</li>
+<li>
+<p>
+<a href="../cowboy_stream.terminate">cowboy_stream:terminate(3)</a> - Terminate a stream
+</p>
+</li>
+<li>
+<p>
+<a href="../cowboy_stream.early_error">cowboy_stream:early_error(3)</a> - Handle an early error for a stream
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_types">Types</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_commands">commands()</h3>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">commands</span></span>() <span style="color: #990000">::</span> [<span style="color: #009900">Command</span>]</tt></pre></div></div>
+<div class="paragraph"><p>See the <a href="../commands">list of commands</a> for details.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_fin">fin()</h3>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">fin</span></span>() <span style="color: #990000">::</span> <span style="color: #FF6600">fin</span> | <span style="color: #FF6600">nofin</span></tt></pre></div></div>
+<div class="paragraph"><p>Used in commands and events to indicate that this is
+the end of the stream.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_partial_req">partial_req()</h3>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">req</span></span>() <span style="color: #990000">::</span> #{
+ <span style="color: #0000FF">method</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #000080">binary</span></span>(), <span style="font-style: italic"><span style="color: #9A1900">%% case sensitive</span></span>
+ <span style="color: #0000FF">version</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #000000">cowboy:http_version</span></span>() | <span style="font-weight: bold"><span style="color: #000080">atom</span></span>(),
+ <span style="color: #0000FF">scheme</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #000080">binary</span></span>(), <span style="font-style: italic"><span style="color: #9A1900">%% lowercase; case insensitive</span></span>
+ <span style="color: #0000FF">host</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #000080">binary</span></span>(), <span style="font-style: italic"><span style="color: #9A1900">%% lowercase; case insensitive</span></span>
+ <span style="color: #0000FF">port</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #000000">inet:port_number</span></span>(),
+ <span style="color: #0000FF">path</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #000080">binary</span></span>(), <span style="font-style: italic"><span style="color: #9A1900">%% case sensitive</span></span>
+ <span style="color: #0000FF">qs</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #000080">binary</span></span>(), <span style="font-style: italic"><span style="color: #9A1900">%% case sensitive</span></span>
+ <span style="color: #0000FF">headers</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #000000">cowboy:http_headers</span></span>(),
+ <span style="color: #0000FF">peer</span> <span style="color: #990000">=&gt;</span> {<span style="font-weight: bold"><span style="color: #000000">inet:ip_address</span></span>(), <span style="font-weight: bold"><span style="color: #000000">inet:port_number</span></span>()}
+}</tt></pre></div></div>
+<div class="paragraph"><p>Partial request information received when an early error is
+detected.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_reason">reason()</h3>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">reason</span></span>() <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000080">normal</span></span> | <span style="color: #FF6600">switch_protocol</span>
+ | {<span style="color: #FF6600">internal_error</span>, <span style="color: #FF6600">timeout</span> | {<span style="color: #FF6600">error</span> | <span style="font-weight: bold"><span style="color: #000080">exit</span></span> | <span style="font-weight: bold"><span style="color: #000080">throw</span></span>, <span style="font-weight: bold"><span style="color: #000000">any</span></span>()}, <span style="color: #009900">HumanReadable</span>}
+ | {<span style="color: #FF6600">socket_error</span>, <span style="color: #FF6600">closed</span> | <span style="font-weight: bold"><span style="color: #000080">atom</span></span>(), <span style="color: #009900">HumanReadable</span>}
+ | {<span style="color: #FF6600">stream_error</span>, <span style="color: #009900">Error</span>, <span style="color: #009900">HumanReadable</span>}
+ | {<span style="color: #FF6600">connection_error</span>, <span style="color: #009900">Error</span>, <span style="color: #009900">HumanReadable</span>}
+ | {<span style="color: #FF6600">stop</span>, <span style="font-weight: bold"><span style="color: #000000">cow_http2:frame</span></span>(), <span style="color: #009900">HumanReadable</span>}
+
+<span style="color: #009900">Error</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000080">atom</span></span>()
+<span style="color: #009900">HumanReadable</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000080">atom</span></span>()</tt></pre></div></div>
+<div class="paragraph"><p>Reason for the stream termination.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_resp_command">resp_command()</h3>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">resp_command</span></span>() <span style="color: #990000">::</span> {<span style="color: #FF6600">response</span>, <span style="font-weight: bold"><span style="color: #000000">cowboy:http_status</span></span>(),
+ <span style="font-weight: bold"><span style="color: #000000">cowboy:http_headers</span></span>(), <span style="font-weight: bold"><span style="color: #000000">cowboy_req:resp_body</span></span>()}</tt></pre></div></div>
+<div class="paragraph"><p>See the <a href="../response_command">response command</a> for details.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_streamid">streamid()</h3>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">streamid</span></span>() <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">any</span></span>()</tt></pre></div></div>
+<div class="paragraph"><p>The identifier for this stream.</p></div>
+<div class="paragraph"><p>The identifier is unique over the connection process.
+It is possible to form a unique identifier node-wide and
+cluster-wide by wrapping it in a <code>{self(), StreamID}</code>
+tuple.</p></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_changelog">Changelog</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+<strong>2.0</strong>: Module introduced.
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_see_also">See also</h2>
+<div class="sectionbody">
+<div class="paragraph"><p><a href="..">cowboy(7)</a>,
+<a href="../cowboy_http">cowboy_http(3)</a>,
+<a href="../cowboy_http2">cowboy_http2(3)</a></p></div>
+</div>
+</div>
+
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Cowboy
+ 2.2
+ Function Reference
+
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/cowboy/2.2/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/cowboy/2.2/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/cowboy/2.2/manual">2.2</a></li>
+
+ <li><a href="/docs/en/cowboy/2.1/manual">2.1</a></li>
+
+ <li><a href="/docs/en/cowboy/2.0/manual">2.0</a></li>
+
+ <li><a href="/docs/en/cowboy/1.0/manual">1.0</a></li>
+
+</ul>
+
+</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-2016</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+