Debian Codegraph @

doc/src/manual/cowboy_req.inform.asciidoc

raw
1 = cowboy_req:inform(3)
2
3 == Name
4
5 cowboy_req:inform - Send an informational response
6
7 == Description
8
9 [source,erlang]
10 ----
11 inform(Status, Req :: cowboy_req:req())
12 -> inform(StatusCode, #{}, Req)
13
14 inform(Status, Headers, Req :: cowboy_req:req())
15 -> ok
16
17 Status :: cowboy:http_status()
18 Headers :: cowboy:http_headers()
19 ----
20
21 Send an informational response.
22
23 Informational responses use a status code between 100 and 199.
24 They cannot include a body. This function will not use any
25 of the previously set headers. All headers to be sent must
26 be given directly.
27
28 Any number of informational responses can be sent as long as
29 they are sent before the proper response. Attempting to use
30 this function after sending a normal response will result
31 in an error.
32
33 The header names must be given as lowercase binary strings.
34 While header names are case insensitive, Cowboy requires them
35 to be given as lowercase to function properly.
36
37 == Arguments
38
39 Status::
40
41 The status code for the response.
42
43 Headers::
44
45 The response headers.
46 +
47 Header names must be given as lowercase binary strings.
48
49 Req::
50
51 The Req object.
52
53 == Return value
54
55 The atom `ok` is always returned. It can be safely ignored.
56
57 == Changelog
58
59 * *2.1*: Function introduced.
60
61 == Examples
62
63 .Send an informational response
64 [source,erlang]
65 ----
66 Req = cowboy_req:inform(102, Req0).
67 ----
68
69 .Send an informational response with headers
70 [source,erlang]
71 ----
72 Req = cowboy_req:inform(103, #{
73 <<"link">> => <<"</style.css>; rel=preload; as=style, "
74 "</script.js>; rel=preload; as=script">>
75 }, Req0).
76 ----
77
78 == See also
79
80 link:man:cowboy_req(3)[cowboy_req(3)],
81 link:man:cowboy_req:reply(3)[cowboy_req:reply(3)],
82 link:man:cowboy_req:stream_reply(3)[cowboy_req:stream_reply(3)],
83 link:man:cowboy_req:push(3)[cowboy_req:push(3)]