Erlang Mailing Lists

Author Message

<  Erlang bugs mailing list  ~  [BUG] erlang:decode_packet/3 generates corrupt header names

Guest
Posted: Sat Mar 20, 2010 11:11 pm Reply with quote
Guest
Hello,

erlang:decode_packet/3 generates strange corrupted header names for
unknown header types when using the httph_bin option. The cause seems
related to the length of the header name, short ones work fine.

Test Case:

test() ->
B = <<
"X-Transaction: 1269062039-39495-905\r\n"
"X-RateLimit-Limit: 150\r\n"
"Content-Type: application/json; charset=utf-8\r\n"
"X-Foo: bar\r\n"
"\r\n"
>>,
{ok, Headers, Rest} = decode_headers(B, []),
io:format("HEADERS:~n~p~n", [Headers]),
io:format("REST:~n~p~n", [Rest]).

decode_headers(Bin, Acc) ->
case erlang:decode_packet(httph_bin, Bin, []) of
{ok, {http_header, _N, _Name, _, _V} = H, Rest} ->
decode_headers(Rest, [H | Acc]);
{ok, http_eoh, Rest} ->
{ok, Acc, Rest}
end.

Result:

Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0]
[hipe] [kernel-poll:false]

HEADERS:
[{http_header,0,<<"X-Foo">>,undefined,<<"bar">>},
{http_header,42,'Content-Type',undefined,
<<"application/json; charset=utf-8">>},
{http_header,0,
<<88,45,70,111,111,50,14,0,64,190,14,1,10,0,0,0,14>>,
undefined,<<"150">>},
{http_header,0,
<<88,45,70,111,111,50,14,0,64,190,14,1,10>>,
undefined,<<"1269062039-39495-905">>}]
REST:
<<>>

________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum