Parsing custom HTTP headers with inet, [{active, false},{packet, http_bin}, ...]

zabrane Mikael <>
Sat Aug 28 12:11:34 CEST 2010


I'm facing a strange problem to parse custom HTTP headers in my server
code which looks like:

{ok, ListenSocket} = gen_tcp:listen(9876, [binary, inet, {active,
false},  {packet, http_bin}, {reuseaddr, true}]),
headers(Socket) ->
    ok = inet:setopts(Socket, [{active, once}]),
        {http, _, {http_header, _, Header, _, Val}} ->
            io:format("---> The header is: ~p: ~p~n", [Header, Val]),

Trying to send the following custom header "X-ARCHWEB-RESOURCE-UUID"
works fine, and the custom header appears
correctly in my server code:
$ curl -x localhost:9876 -H 'X-ARCHWEB-RESOURCE-UUID: 123456789' --url

1> ...
---> The header is: <<"X-ARCHWEB-RESOURCE-UUID">>: <<"123456789">>

But changing a bit the custom header name to "X-WEBARCH-RESOURCE-UUID"
doesn't work
and the server don't even print it out (i.e nothing is received).

Now, trying with "X-WEBARCH-RESOURC-UUID" (notice the missing "E" at
the end of "RESOURC") works fine:

2> ...
---> The header is: <<"X-WEBARCH-RESOURC-UUID">>: <<"123456789">>

Even bad, trying with "X-WEBARCH-RESOURCE" completely alter the
letters cases (first letter is capital letter and the rest is

---> The header is: <<"X-Webarch-Resource">>: <<"123456789">>

Could someone tell me what am I doing wrong?
Is there any option to tell "inet" to not alter the headers at all?


More information about the erlang-questions mailing list