Debian Codegraph @

doc/src/manual/cowboy_req.resp_header.asciidoc

raw
1 = cowboy_req:resp_header(3)
2
3 == Name
4
5 cowboy_req:resp_header - Response header
6
7 == Description
8
9 [source,erlang]
10 ----
11 resp_header(Name, Req) -> resp_header(Name, Req, undefined)
12 resp_header(Name, Req, Default) -> binary() | Default
13
14 Name :: binary() %% lowercase; case insensitive
15 Req :: cowboy_req:req()
16 Default :: any()
17 ----
18
19 Return the value for the given response header.
20
21 The response header must have been set previously using
22 link:man:cowboy_req:set_resp_header(3)[cowboy_req:set_resp_header(3)] or
23 link:man:cowboy_req:set_resp_headers(3)[cowboy_req:set_resp_headers(3)].
24
25 The header name must be given as a lowercase binary string.
26 While header names are case insensitive, Cowboy requires them
27 to be given as lowercase to function properly.
28
29 == Arguments
30
31 Name::
32
33 Desired response header name as a lowercase binary string.
34
35 Req::
36
37 The Req object.
38
39 Default::
40
41 Default value returned when the header is missing.
42
43 == Return value
44
45 The header value is returned as a binary string. When the
46 header is missing, the default argument is returned.
47
48 == Changelog
49
50 * *2.0*: Function introduced.
51
52 == Examples
53
54 .Get the content-type response header
55 [source,erlang]
56 ----
57 Type = cowboy_req:resp_header(<<"content-type">>, Req).
58 ----
59
60 .Get the content-type response header with a default value
61 [source,erlang]
62 ----
63 Type = cowboy_req:resp_header(<<"content-type">>, Req, <<"text/html">>).
64 ----
65
66 == See also
67
68 link:man:cowboy_req(3)[cowboy_req(3)],
69 link:man:cowboy_req:resp_headers(3)[cowboy_req:resp_headers(3)],
70 link:man:cowboy_req:set_resp_header(3)[cowboy_req:set_resp_header(3)],
71 link:man:cowboy_req:set_resp_headers(3)[cowboy_req:set_resp_headers(3)]