diff options
Diffstat (limited to 'docs/en/cowboy/2.2/guide/streams/index.html')
-rw-r--r-- | docs/en/cowboy/2.2/guide/streams/index.html | 68 |
1 files changed, 15 insertions, 53 deletions
diff --git a/docs/en/cowboy/2.2/guide/streams/index.html b/docs/en/cowboy/2.2/guide/streams/index.html index a5a1e9a4..c4758381 100644 --- a/docs/en/cowboy/2.2/guide/streams/index.html +++ b/docs/en/cowboy/2.2/guide/streams/index.html @@ -62,61 +62,23 @@ <h1 class="lined-header"><span>Streams</span></h1> -<div class="paragraph"><p>A stream is the set of messages that form an HTTP -request/response pair.</p></div> -<div class="paragraph"><p>The term stream comes from HTTP/2. In Cowboy, it is -also used when talking about HTTP/1.1 or HTTP/1.0. -It should not be confused with streaming the request -or response body.</p></div> -<div class="paragraph"><p>All versions of HTTP allow clients to initiate -streams. HTTP/2 is the only one also allowing servers, -through its server push feature. Both client and -server-initiated streams go through the same process -in Cowboy.</p></div> -<div class="sect1"> +<p>A stream is the set of messages that form an HTTP request/response pair.</p> +<p>The term stream comes from HTTP/2. In Cowboy, it is also used when talking about HTTP/1.1 or HTTP/1.0. It should not be confused with streaming the request or response body.</p> +<p>All versions of HTTP allow clients to initiate streams. HTTP/2 is the only one also allowing servers, through its server push feature. Both client and server-initiated streams go through the same process in Cowboy.</p> <h2 id="_stream_handlers">Stream handlers</h2> -<div class="sectionbody"> -<div class="paragraph"><p>Stream handlers must implement five different callbacks. -Four of them are directly related; one is special.</p></div> -<div class="paragraph"><p>All callbacks receives the stream ID as first argument.</p></div> -<div class="paragraph"><p>Most of them can return a list of commands to be executed -by Cowboy. When callbacks are chained, it is possible to -intercept and modify these commands. This can be useful -for modifying responses for example.</p></div> -<div class="paragraph"><p>The <code>init/3</code> callback is invoked when a new request -comes in. It receives the Req object and the protocol options -for this listener.</p></div> -<div class="paragraph"><p>The <code>data/4</code> callback is invoked when data from the request -body is received. It receives both this data and a flag -indicating whether more is to be expected.</p></div> -<div class="paragraph"><p>The <code>info/3</code> callback is invoked when an Erlang message is -received for this stream. They will typically be messages -sent by the request process.</p></div> -<div class="paragraph"><p>Finally the <code>terminate/3</code> callback is invoked with the -terminate reason for the stream. The return value is ignored. -Note that as with all terminate callbacks in Erlang, there -is no strong guarantee that it will be called.</p></div> -<div class="paragraph"><p>The special callback <code>early_error/5</code> is called when an error -occurs before the request headers were fully received and -Cowboy is sending a response. It receives the partial Req -object, the error reason, the protocol options and the response -Cowboy will send. This response must be returned, possibly -modified.</p></div> -</div> -</div> -<div class="sect1"> +<p>Stream handlers must implement five different callbacks. Four of them are directly related; one is special.</p> +<p>All callbacks receives the stream ID as first argument.</p> +<p>Most of them can return a list of commands to be executed by Cowboy. When callbacks are chained, it is possible to intercept and modify these commands. This can be useful for modifying responses for example.</p> +<p>The <code>init/3</code> callback is invoked when a new request comes in. It receives the Req object and the protocol options for this listener.</p> +<p>The <code>data/4</code> callback is invoked when data from the request body is received. It receives both this data and a flag indicating whether more is to be expected.</p> +<p>The <code>info/3</code> callback is invoked when an Erlang message is received for this stream. They will typically be messages sent by the request process.</p> +<p>Finally the <code>terminate/3</code> callback is invoked with the terminate reason for the stream. The return value is ignored. Note that as with all terminate callbacks in Erlang, there is no strong guarantee that it will be called.</p> +<p>The special callback <code>early_error/5</code> is called when an error occurs before the request headers were fully received and Cowboy is sending a response. It receives the partial Req object, the error reason, the protocol options and the response Cowboy will send. This response must be returned, possibly modified.</p> <h2 id="_built_in_handlers">Built-in handlers</h2> -<div class="sectionbody"> -<div class="paragraph"><p>Cowboy comes with two handlers.</p></div> -<div class="paragraph"><p><code>cowboy_stream_h</code> is the default stream handler. -It is the core of much of the functionality of Cowboy. -All chains of stream handlers should call it last.</p></div> -<div class="paragraph"><p><code>cowboy_compress_h</code> will automatically compress -responses when possible. It is not enabled by default. -It is a good example for writing your own handlers -that will modify responses.</p></div> -</div> -</div> +<p>Cowboy comes with two handlers.</p> +<p><code>cowboy_stream_h</code> is the default stream handler. It is the core of much of the functionality of Cowboy. All chains of stream handlers should call it last.</p> +<p><code>cowboy_compress_h</code> will automatically compress responses when possible. It is not enabled by default. It is a good example for writing your own handlers that will modify responses.</p> + |