diff options
Diffstat (limited to 'docs/en/cowboy/2.3/manual/cowboy_req.reply')
-rw-r--r-- | docs/en/cowboy/2.3/manual/cowboy_req.reply/index.html | 190 |
1 files changed, 56 insertions, 134 deletions
diff --git a/docs/en/cowboy/2.3/manual/cowboy_req.reply/index.html b/docs/en/cowboy/2.3/manual/cowboy_req.reply/index.html index 602df6ad..564db588 100644 --- a/docs/en/cowboy/2.3/manual/cowboy_req.reply/index.html +++ b/docs/en/cowboy/2.3/manual/cowboy_req.reply/index.html @@ -62,165 +62,87 @@ <h1 class="lined-header"><span>cowboy_req:reply(3)</span></h1> -<div class="sect1"> <h2 id="_name">Name</h2> -<div class="sectionbody"> -<div class="paragraph"><p>cowboy_req:reply - Send the response</p></div> -</div> -</div> -<div class="sect1"> +<p>cowboy_req:reply - Send the response</p> <h2 id="_description">Description</h2> -<div class="sectionbody"> -<div class="listingblock"> -<div class="content"><!-- Generator: GNU source-highlight +<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">reply</span></span>(<span style="color: #009900">Status</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: #990000">-></span> <span style="font-weight: bold"><span style="color: #000000">reply</span></span>(<span style="color: #009900">StatusCode</span>, #{}, <span style="color: #009900">Req</span>) - -<span style="font-weight: bold"><span style="color: #000000">reply</span></span>(<span style="color: #009900">Status</span>, <span style="color: #009900">Headers</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: #990000">-></span> <span style="color: #009900">Req</span> - -<span style="font-weight: bold"><span style="color: #000000">reply</span></span>(<span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>, <span style="color: #009900">Body</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: #990000">-></span> <span style="color: #009900">Req</span> - -<span style="color: #009900">Status</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy:http_status</span></span>() -<span style="color: #009900">Headers</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy:http_headers</span></span>() -<span style="color: #009900">Body</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:resp_body</span></span>()</tt></pre></div></div> -<div class="paragraph"><p>Send the response.</p></div> -<div class="paragraph"><p>The header names must be given as lowercase binary strings. -While header names are case insensitive, Cowboy requires them -to be given as lowercase to function properly.</p></div> -<div class="paragraph"><p>Cowboy does not allow duplicate header names. Headers set -by this function may overwrite those set by <code>set_resp_header/3</code> -and <code>set_resp_headers/2</code>.</p></div> -<div class="paragraph"><p>Use <a href="../cowboy_req.set_resp_cookie">cowboy_req:set_resp_cookie(3)</a> -instead of this function to set cookies.</p></div> -<div class="paragraph"><p>The <code>reply/2,3</code> functions will send the body set previously, -if any. The <code>reply/4</code> function always sends the given body, -overriding any previously set.</p></div> -<div class="paragraph"><p>You do not need to set the content-length header when -sending a response body. Cowboy takes care of it automatically. -You should however provide a content-type header.</p></div> -<div class="paragraph"><p>No further data can be transmitted after this function -returns. This includes the push mechanism. Attempting to -send two replies, or to push resources after a reply has -been sent, will result in an error.</p></div> -</div> -</div> -<div class="sect1"> +<pre><tt><b><font color="#000000">reply</font></b>(<font color="#009900">Status</font>, <font color="#009900">Req</font> <font color="#990000">::</font> <b><font color="#000000">cowboy_req:req</font></b>()) + <font color="#990000">-></font> <b><font color="#000000">reply</font></b>(<font color="#009900">StatusCode</font>, #{}, <font color="#009900">Req</font>) + +<b><font color="#000000">reply</font></b>(<font color="#009900">Status</font>, <font color="#009900">Headers</font>, <font color="#009900">Req</font> <font color="#990000">::</font> <b><font color="#000000">cowboy_req:req</font></b>()) + <font color="#990000">-></font> <font color="#009900">Req</font> + +<b><font color="#000000">reply</font></b>(<font color="#009900">Status</font>, <font color="#009900">Headers</font>, <font color="#009900">Body</font>, <font color="#009900">Req</font> <font color="#990000">::</font> <b><font color="#000000">cowboy_req:req</font></b>()) + <font color="#990000">-></font> <font color="#009900">Req</font> + +<font color="#009900">Status</font> <font color="#990000">::</font> <b><font color="#000000">cowboy:http_status</font></b>() +<font color="#009900">Headers</font> <font color="#990000">::</font> <b><font color="#000000">cowboy:http_headers</font></b>() +<font color="#009900">Body</font> <font color="#990000">::</font> <b><font color="#000000">cowboy_req:resp_body</font></b>()</tt></pre> +</div></div> +<p>Send the response.</p> +<p>The header names must be given as lowercase binary strings. While header names are case insensitive, Cowboy requires them to be given as lowercase to function properly.</p> +<p>Cowboy does not allow duplicate header names. Headers set by this function may overwrite those set by <code>set_resp_header/3</code> and <code>set_resp_headers/2</code>.</p> +<p>Use <a href="../cowboy_req.set_resp_cookie">cowboy_req:set_resp_cookie(3)</a> instead of this function to set cookies.</p> +<p>The <code>reply/2,3</code> functions will send the body set previously, if any. The <code>reply/4</code> function always sends the given body, overriding any previously set.</p> +<p>You do not need to set the content-length header when sending a response body. Cowboy takes care of it automatically. You should however provide a content-type header.</p> +<p>No further data can be transmitted after this function returns. This includes the push mechanism. Attempting to send two replies, or to push resources after a reply has been sent, will result in an error.</p> <h2 id="_arguments">Arguments</h2> -<div class="sectionbody"> -<div class="dlist"><dl> -<dt class="hdlist1"> -Status -</dt> -<dd> -<p> -The status code for the response. -</p> +<dl><dt>Status</dt> +<dd><p>The status code for the response.</p> </dd> -<dt class="hdlist1"> -Headers -</dt> -<dd> -<p> -The response headers. -</p> +<dt>Headers</dt> +<dd><p>The response headers.</p> </dd> -</dl></div> -<div class="paragraph"><p>Header names must be given as lowercase binary strings.</p></div> -<div class="dlist"><dl> -<dt class="hdlist1"> -Body -</dt> -<dd> -<p> -The body can be either a binary value, an iolist or a -<code>sendfile</code> tuple telling Cowboy to send the contents of -a file. -</p> +</dl> +<p>Header names must be given as lowercase binary strings.</p> +<dl><dt>Body</dt> +<dd><p>The body can be either a binary value, an iolist or a <code>sendfile</code> tuple telling Cowboy to send the contents of a file.</p> </dd> -<dt class="hdlist1"> -Req -</dt> -<dd> -<p> -The Req object. -</p> +<dt>Req</dt> +<dd><p>The Req object.</p> </dd> -</dl></div> -</div> -</div> -<div class="sect1"> +</dl> <h2 id="_return_value">Return value</h2> -<div class="sectionbody"> -<div class="paragraph"><p>A new Req object is returned.</p></div> -<div class="paragraph"><p>The returned Req object should be used from that point onward -as it contains updated information about the state of the request.</p></div> -</div> -</div> -<div class="sect1"> +<p>A new Req object is returned.</p> +<p>The returned Req object should be used from that point onward as it contains updated information about the state of the request.</p> <h2 id="_changelog">Changelog</h2> -<div class="sectionbody"> -<div class="ulist"><ul> -<li> -<p> -<strong>2.0</strong>: Only the Req is returned, it is no longer wrapped in a tuple. -</p> +<ul><li><strong>2.0</strong>: Only the Req is returned, it is no longer wrapped in a tuple. </li> -<li> -<p> -<strong>1.0</strong>: Function introduced. -</p> +<li><strong>1.0</strong>: Function introduced. </li> -</ul></div> -</div> -</div> -<div class="sect1"> +</ul> <h2 id="_examples">Examples</h2> -<div class="sectionbody"> -<div class="listingblock"> -<div class="title">Reply</div> -<div class="content"><!-- Generator: GNU source-highlight +<div class="listingblock"><div class="title">Reply</div> +<div class="content"><!-- Generator: GNU source-highlight 3.1.8 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -<pre><tt><span style="color: #009900">Req</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">404</span>, <span style="color: #009900">Req0</span>)<span style="color: #990000">.</span></tt></pre></div></div> -<div class="listingblock"> -<div class="title">Reply with custom headers</div> -<div class="content"><!-- Generator: GNU source-highlight +<pre><tt><font color="#009900">Req</font> <font color="#990000">=</font> <b><font color="#000000">cowboy_req:reply</font></b>(<font color="#993399">404</font>, <font color="#009900">Req0</font>)<font color="#990000">.</font></tt></pre> +</div></div> +<div class="listingblock"><div class="title">Reply with custom headers</div> +<div class="content"><!-- Generator: GNU source-highlight 3.1.8 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -<pre><tt><span style="color: #009900">Req</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">401</span>, #{ - <span style="color: #990000"><<</span><span style="color: #FF0000">"www-authenticate"</span><span style="color: #990000">>></span> <span style="color: #990000">=></span> <span style="color: #990000"><<</span><span style="color: #FF0000">"Basic realm=\"erlang.org\""</span><span style="color: #990000">>></span> -}, <span style="color: #009900">Req0</span>)<span style="color: #990000">.</span></tt></pre></div></div> -<div class="listingblock"> -<div class="title">Reply with custom headers and a body</div> -<div class="content"><!-- Generator: GNU source-highlight +<pre><tt><font color="#009900">Req</font> <font color="#990000">=</font> <b><font color="#000000">cowboy_req:reply</font></b>(<font color="#993399">401</font>, #{ + <font color="#990000"><<</font><font color="#FF0000">"www-authenticate"</font><font color="#990000">>></font> <font color="#990000">=></font> <font color="#990000"><<</font><font color="#FF0000">"Basic realm=\"erlang.org\""</font><font color="#990000">>></font> +}, <font color="#009900">Req0</font>)<font color="#990000">.</font></tt></pre> +</div></div> +<div class="listingblock"><div class="title">Reply with custom headers and a body</div> +<div class="content"><!-- Generator: GNU source-highlight 3.1.8 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -<pre><tt><span style="color: #009900">Req</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, #{ - <span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span> <span style="color: #990000">=></span> <span style="color: #990000"><<</span><span style="color: #FF0000">"text/plain"</span><span style="color: #990000">>></span> -}, <span style="color: #FF0000">"Hello world!"</span>, <span style="color: #009900">Req0</span>)<span style="color: #990000">.</span></tt></pre></div></div> -</div> -</div> -<div class="sect1"> +<pre><tt><font color="#009900">Req</font> <font color="#990000">=</font> <b><font color="#000000">cowboy_req:reply</font></b>(<font color="#993399">200</font>, #{ + <font color="#990000"><<</font><font color="#FF0000">"content-type"</font><font color="#990000">>></font> <font color="#990000">=></font> <font color="#990000"><<</font><font color="#FF0000">"text/plain"</font><font color="#990000">>></font> +}, <font color="#FF0000">"Hello world!"</font>, <font color="#009900">Req0</font>)<font color="#990000">.</font></tt></pre> +</div></div> <h2 id="_see_also">See also</h2> -<div class="sectionbody"> -<div class="paragraph"><p><a href="../cowboy_req">cowboy_req(3)</a>, -<a href="../cowboy_req.set_resp_cookie">cowboy_req:set_resp_cookie(3)</a>, -<a href="../cowboy_req.set_resp_header">cowboy_req:set_resp_header(3)</a>, -<a href="../cowboy_req.set_resp_headers">cowboy_req:set_resp_headers(3)</a>, -<a href="../cowboy_req.set_resp_body">cowboy_req:set_resp_body(3)</a>, -<a href="../cowboy_req.inform">cowboy_req:inform(3)</a>, -<a href="../cowboy_req.stream_reply">cowboy_req:stream_reply(3)</a>, -<a href="../cowboy_req.push">cowboy_req:push(3)</a></p></div> -</div> -</div> +<p><a href="../cowboy_req">cowboy_req(3)</a>, <a href="../cowboy_req.set_resp_cookie">cowboy_req:set_resp_cookie(3)</a>, <a href="../cowboy_req.set_resp_header">cowboy_req:set_resp_header(3)</a>, <a href="../cowboy_req.set_resp_headers">cowboy_req:set_resp_headers(3)</a>, <a href="../cowboy_req.set_resp_body">cowboy_req:set_resp_body(3)</a>, <a href="../cowboy_req.inform">cowboy_req:inform(3)</a>, <a href="../cowboy_req.stream_reply">cowboy_req:stream_reply(3)</a>, <a href="../cowboy_req.push">cowboy_req:push(3)</a></p> + |