[erlang-questions] gen_tcp and large HTTP headers

Roberto Ostinelli roberto@REDACTED
Wed Jun 22 21:53:18 CEST 2011


additional information: this can be solved simply by setting:
{recbuf, 2000}

any reasons for keeping this value to minimum sizes?


2011/6/22 Roberto Ostinelli <roberto@REDACTED>

> dear list,
>
> i'm using gen_tcp in {packet, http} and {active, once} modes to receive
> HTTP requests.
>
> 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.
>



-- 
-------------------------------------------------------------------
Roberto Ostinelli
CTO, WideTag Inc. - Realtime, Social, Green
widetag.com
skype: rostinelli
twitter: ostinelli
mobile: +39 335 6 100 22 6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110622/b8c0ca98/attachment.htm>


More information about the erlang-questions mailing list