| 1 |
= cowboy_req:headers(3) |
| 2 |
|
| 3 |
== Name |
| 4 |
|
| 5 |
cowboy_req:headers - HTTP headers |
| 6 |
|
| 7 |
== Description |
| 8 |
|
| 9 |
[source,erlang] |
| 10 |
---- |
| 11 |
headers(Req :: cowboy_req:req()) -> cowboy:http_headers() |
| 12 |
---- |
| 13 |
|
| 14 |
Return all request headers. |
| 15 |
|
| 16 |
Request headers can also be obtained using pattern matching: |
| 17 |
|
| 18 |
[source,erlang] |
| 19 |
---- |
| 20 |
#{headers := Headers} = Req. |
| 21 |
---- |
| 22 |
|
| 23 |
== Arguments |
| 24 |
|
| 25 |
Req:: |
| 26 |
|
| 27 |
The Req object. |
| 28 |
|
| 29 |
== Return value |
| 30 |
|
| 31 |
Headers are returned as a map with keys being lowercase |
| 32 |
binary strings, and values as binary strings. |
| 33 |
|
| 34 |
== Changelog |
| 35 |
|
| 36 |
* *2.0*: Only the headers are returned, they are no longer wrapped in a tuple. |
| 37 |
* *1.0*: Function introduced. |
| 38 |
|
| 39 |
== Examples |
| 40 |
|
| 41 |
.Get all headers |
| 42 |
[source,erlang] |
| 43 |
---- |
| 44 |
Headers = cowboy_req:headers(Req). |
| 45 |
---- |
| 46 |
|
| 47 |
== See also |
| 48 |
|
| 49 |
link:man:cowboy_req(3)[cowboy_req(3)], |
| 50 |
link:man:cowboy_req:header(3)[cowboy_req:header(3)], |
| 51 |
link:man:cowboy_req:parse_header(3)[cowboy_req:parse_header(3)] |