[erlang-bugs] decode_packet doesn't ignore empty lines when decoding the request line

Benoit Chesneau bchesneau@REDACTED
Thu Jun 6 16:15:26 CEST 2013


Erlang version R16B (erts 5.10.1)

     4> Test2 = iolist_to_binary([[<<"\r\n">> || _ <- lists:seq(0,10)], Test1]).
     <<"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nGET /
HTTP/1.1\r\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"...>>
    16> erlang:decode_packet(http_bin, Test2, [{packet_size, 4092}]).
    {ok,{http_error,<<"\r\n">>},
    <<"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nGET /
HTTP/1.1\r\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"...>>}

According to the spec empty lines before the request lines should be ignored:

    In the interest of robustness, servers SHOULD ignore any empty
line(s) received where a Request-Line is expected. In other words, if
the server is reading the protocol stream at the beginning of a
message and receives a CRLF first, it should ignore the CRLF.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.1

Imo, decode_packet should just ignore them instead of returning an
error. In the case a packet_sixe isn't given maybe thenumber of empty
lines can also be set ( or just rely on default packet size).


- benoit



More information about the erlang-bugs mailing list