Debian Codegraph @

doc/src/manual/cowboy_req.set_resp_header.asciidoc

raw
1 = cowboy_req:set_resp_header(3)
2
3 == Name
4
5 cowboy_req:set_resp_header - Set a response header
6
7 == Description
8
9 [source,erlang]
10 ----
11 set_resp_header(Name, Value, Req :: cowboy_req:req())
12 -> Req
13
14 Name :: binary() %% lowercase; case insensitive
15 Value :: iodata() %% case depends on header
16 ----
17
18 Set a header to be sent with the response.
19
20 The header name must be given as a lowercase binary string.
21 While header names are case insensitive, Cowboy requires them
22 to be given as lowercase to function properly.
23
24 Cowboy does not allow duplicate header names. Headers set
25 by this function may be overwritten by those set from the
26 reply functions.
27
28 Use link:man:cowboy_req:set_resp_cookie(3)[cowboy_req:set_resp_cookie(3)]
29 instead of this function to set cookies.
30
31 == Arguments
32
33 Name::
34
35 Header name as a lowercase binary string.
36
37 Value::
38
39 Header value.
40
41 Req::
42
43 The Req object.
44
45 == Return value
46
47 A new Req object is returned.
48
49 The returned Req object must be used from that point onward,
50 otherwise the header will not be sent in the response.
51
52 == Changelog
53
54 * *1.0*: Function introduced.
55
56 == Examples
57
58 .Set a header in the response
59 [source,erlang]
60 ----
61 Req = cowboy_req:set_resp_header(<<"allow">>, "GET", Req0).
62 ----
63
64 .Construct a header using iolists
65 [source,erlang]
66 ----
67 Req = cowboy_req:set_resp_header(<<"allow">>,
68 [allowed_methods(), ", OPTIONS"], Req0).
69 ----
70
71 == See also
72
73 link:man:cowboy_req(3)[cowboy_req(3)],
74 link:man:cowboy_req:set_resp_cookie(3)[cowboy_req:set_resp_cookie(3)],
75 link:man:cowboy_req:set_resp_headers(3)[cowboy_req:set_resp_headers(3)],
76 link:man:cowboy_req:has_resp_header(3)[cowboy_req:has_resp_header(3)],
77 link:man:cowboy_req:resp_header(3)[cowboy_req:resp_header(3)],
78 link:man:cowboy_req:resp_headers(3)[cowboy_req:resp_headers(3)],
79 link:man:cowboy_req:delete_resp_header(3)[cowboy_req:delete_resp_header(3)],
80 link:man:cowboy_req:reply(3)[cowboy_req:reply(3)],
81 link:man:cowboy_req:stream_reply(3)[cowboy_req:stream_reply(3)]