path: root/doc/src/manual/cowboy_req.resp_header.asciidoc
diff options
authorLoïc Hoguin <[email protected]>2017-01-04 19:21:23 +0100
committerLoïc Hoguin <[email protected]>2017-01-04 19:21:23 +0100
commitf34ef2ceae4bccd49f3a655e311c310b7570e64f (patch)
tree2bc6eac95238852b97d544c680937117ec062c25 /doc/src/manual/cowboy_req.resp_header.asciidoc
parent3f4e79d42f7a81fa3f8e790630f71570287c2be0 (diff)
Improve the manual for the new resp_header functions
Diffstat (limited to 'doc/src/manual/cowboy_req.resp_header.asciidoc')
1 files changed, 21 insertions, 11 deletions
diff --git a/doc/src/manual/cowboy_req.resp_header.asciidoc b/doc/src/manual/cowboy_req.resp_header.asciidoc
index 84713ef..52f95d6 100644
--- a/doc/src/manual/cowboy_req.resp_header.asciidoc
+++ b/doc/src/manual/cowboy_req.resp_header.asciidoc
@@ -2,7 +2,7 @@
== Name
-cowboy_req:resp_header - Access the named HTTP header set for the response
+cowboy_req:resp_header - Response header
== Description
@@ -11,18 +11,26 @@ cowboy_req:resp_header - Access the named HTTP header set for the response
resp_header(Name, Req) -> resp_header(Name, Req, undefined)
resp_header(Name, Req, Default) -> binary() | Default
-Name :: binary()
+Name :: binary() %% lowercase; case insensitive
Req :: cowboy_req:req()
Default :: any()
-Return the currently set response header value for the given HTTP header.
+Return the value for the given response header.
+The response header must have been set previously using
+link:man:cowboy_req:set_resp_header(3)[cowboy_req:set_resp_header(3)] or
+The header name must be given as a lowercase binary string.
+While header names are case insensitive, Cowboy requires them
+to be given as lowercase to function properly.
== Arguments
-Desired response HTTP header name as a binary.
+Desired response header name as a lowercase binary string.
@@ -34,7 +42,8 @@ Default value returned when the header is missing.
== Return value
-The binary value for the given HTTP header name.
+The header value is returned as a binary string. When the
+header is missing, the default argument is returned.
== Changelog
@@ -42,20 +51,21 @@ The binary value for the given HTTP header name.
== Examples
-.Get the response header with the given name
+.Get the content-type response header
-HeaderValue = cowboy_req:resp_header(<<"x-test-header">>, Req).
+Type = cowboy_req:resp_header(<<"content-type">>, Req).
-.Get the response header with the given name and a default
+.Get the content-type response header with a default value
-HeaderValue = cowboy_req:resp_header(<<"x-test-header">>, Req, <<"bar">>).
+Type = cowboy_req:resp_header(<<"content-type">>, Req, <<"text/html">>).
== See also