[erlang-bugs] erlang:decode_packet/3 issues

Loïc Hoguin essen@REDACTED
Tue Aug 23 12:49:54 CEST 2011


Hello,

Sorry if it has already been reported but I'd like to point to two
issues in erlang:decode_packet/3: one is a bug, the other just an
annoying limitation.

There is a bug in erlang:decode_packet/3 that happens when we have an
header name with a - following another. If we have an even number of -,
then the following character is lowercase, otherwise it's uppercase:

1> erlang:decode_packet(httph, <<"test-test: test\r\n\r\n">>, []).
{ok,{http_header,0,"Test-Test",undefined,"test"},<<"\r\n">>}
2> erlang:decode_packet(httph, <<"test--test: test\r\n\r\n">>, []).
{ok,{http_header,0,"Test--test",undefined,"test"},
    <<"\r\n">>}
3> erlang:decode_packet(httph, <<"test---test: test\r\n\r\n">>, []).
{ok,{http_header,0,"Test---Test",undefined,"test"},
    <<"\r\n">>}

The other issue comes when we have header names bigger than 20
characters in length. It's a bit low for some header names, for example
Sec-Websocket-Version:

4> erlang:decode_packet(httph, <<"sec-websocket-version: 8\r\n\r\n">>, []).
{ok,{http_header,0,"sec-websocket-version",undefined,"8"},
    <<"\r\n">>}
5> erlang:decode_packet(httph, <<"sec-websocket-versio: 8\r\n\r\n">>, []).
{ok,{http_header,0,"Sec-Websocket-Versio",undefined,"8"},
    <<"\r\n">>}

It would be appreciated if that number could be increased at least a
little or be made configurable. Otherwise we end up having to write the
same code in our applications to handle the longer header names.

-- 
Loïc Hoguin
Dev:Extend



More information about the erlang-bugs mailing list