[erlang-questions] gen_tcp and large HTTP headers

Roberto Ostinelli <>
Wed Jun 22 21:44:30 CEST 2011


dear list,

i'm using gen_tcp in {packet, http} and {active, once} modes to
receive HTTPrequests.

whenever i use a very large GET header, like such:
http://localhost:8080/foo?var=foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar

the controlling process receives from the socket the message:
{SocketMode, Sock,
    {http_error, "oobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
HTTP/1.1\r\n"}}

this looks to me like a MTU issue: the GET header is larger than the MTU,
and thus the erlang:decode_packet/3 returns the error of a badly formed HTTP
header since it is not complete.

since i'm in active mode, my loop looks like this:

headers(Sock, H) ->
    gen_tcp:setopts(Sock, [{active, once}]),
    receive
        {SocketMode, Sock, {http_header, _, Header, _, Val} = _Head} ->
            headers(Sock, [{Header, Val}|H]);

        ...

    end.

thus, should i use an accumulator? but then should i manually trigger
the erlang:decode_packet/3
function?

thank you for any insights on this.

r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110622/683f8011/attachment.html>


More information about the erlang-questions mailing list