From d2a3f2cedd7c00d0933222aed9c06b3149aa4db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 4 Apr 2018 13:13:37 +0200 Subject: Cowboy 2.3.0 --- .../cowboy/2.3/manual/cowboy_req.reply/index.html | 304 +++++++++++++++++++++ 1 file changed, 304 insertions(+) create mode 100644 docs/en/cowboy/2.3/manual/cowboy_req.reply/index.html (limited to 'docs/en/cowboy/2.3/manual/cowboy_req.reply') 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 new file mode 100644 index 00000000..c01b9564 --- /dev/null +++ b/docs/en/cowboy/2.3/manual/cowboy_req.reply/index.html @@ -0,0 +1,304 @@ + + + + + + + + + + + + Nine Nines: cowboy_req:reply(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

cowboy_req:reply(3)

+ +
+

Name

+
+

cowboy_req:reply - Send the response

+
+
+
+

Description

+
+
+
+
reply(Status, Req :: cowboy_req:req())
+    -> reply(StatusCode, #{}, Req)
+
+reply(Status, Headers, Req :: cowboy_req:req())
+    -> Req
+
+reply(Status, Headers, Body, Req :: cowboy_req:req())
+    -> Req
+
+Status  :: cowboy:http_status()
+Headers :: cowboy:http_headers()
+Body    :: cowboy_req:resp_body()
+

Send the response.

+

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.

+

Cowboy does not allow duplicate header names. Headers set +by this function may overwrite those set by set_resp_header/3 +and set_resp_headers/2.

+

Use cowboy_req:set_resp_cookie(3) +instead of this function to set cookies.

+

The reply/2,3 functions will send the body set previously, +if any. The reply/4 function always sends the given body, +overriding any previously set.

+

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.

+

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.

+
+
+
+

Arguments

+
+
+
+Status +
+
+

+The status code for the response. +

+
+
+Headers +
+
+

+The response headers. +

+
+
+

Header names must be given as lowercase binary strings.

+
+
+Body +
+
+

+The body can be either a binary value, an iolist or a +sendfile tuple telling Cowboy to send the contents of +a file. +

+
+
+Req +
+
+

+The Req object. +

+
+
+
+
+
+

Return value

+
+

A new Req object is returned.

+

The returned Req object should be used from that point onward +as it contains updated information about the state of the request.

+
+
+
+

Changelog

+
+
    +
  • +

    +2.0: Only the Req is returned, it is no longer wrapped in a tuple. +

    +
  • +
  • +

    +1.0: Function introduced. +

    +
  • +
+
+
+
+

Examples

+
+
+
Reply
+
+
Req = cowboy_req:reply(404, Req0).
+
+
Reply with custom headers
+
+
Req = cowboy_req:reply(401, #{
+    <<"www-authenticate">> => <<"Basic realm=\"erlang.org\"">>
+}, Req0).
+
+
Reply with custom headers and a body
+
+
Req = cowboy_req:reply(200, #{
+    <<"content-type">> => <<"text/plain">>
+}, "Hello world!", Req0).
+
+
+ + + + + + +
+ +
+ + +

+ Cowboy + 2.3 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + -- cgit v1.2.3