aboutsummaryrefslogtreecommitdiffstats
path: root/guide/internals.md
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-01-17 23:37:50 +0100
committerLoïc Hoguin <[email protected]>2013-01-17 23:37:50 +0100
commit1b996794eedbfee87997cde8d05d8fae9548094a (patch)
treefb504833525a80f223d2eedb61384e36c60369f9 /guide/internals.md
parentcd680706cd0aaff9f92481490babbbffcd117b0a (diff)
downloadcowboy-1b996794eedbfee87997cde8d05d8fae9548094a.tar.gz
cowboy-1b996794eedbfee87997cde8d05d8fae9548094a.tar.bz2
cowboy-1b996794eedbfee87997cde8d05d8fae9548094a.zip
Add cowboy_bstr:capitalize_token/1
For optional header name capitalization. See the guide section about it.
Diffstat (limited to 'guide/internals.md')
-rw-r--r--guide/internals.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/guide/internals.md b/guide/internals.md
index 431ca01..8acf75b 100644
--- a/guide/internals.md
+++ b/guide/internals.md
@@ -6,6 +6,30 @@ Architecture
@todo Describe.
+Lowercase header names
+----------------------
+
+For consistency reasons it has been chosen to convert all header names
+to lowercase binary strings. This prevents the programmer from making
+case mistakes, and is possible because header names are case insensitive.
+
+This works fine for the large majority of clients. However, some badly
+implemented clients, especially ones found in corporate code or closed
+source products, may not handle header names in a case insensitive manner.
+This means that when Cowboy returns lowercase header names, these clients
+will not find the headers they are looking for.
+
+A simple way to solve this is to create an `onresponse` hook that will
+format the header names with the expected case.
+
+``` erlang
+capitalize_hook(Status, Headers, Body, Req) ->
+ Headers2 = [{cowboy_bstr:capitalize_token(N), V}
+ || {N, V} <- Headers],
+ {ok, Req2} = cowboy_req:reply(State, Headers2, Body, Req),
+ Req2.
+```
+
Efficiency considerations
-------------------------