[erlang-questions] erlang http tcp_closed problem

Przemysław Wycisk p.wycisk@REDACTED
Sun Feb 8 19:25:34 CET 2015

I've got problem with using erlang active http socket.

I receive msgs like that:

ok = inet:setopts(Sock,[{active, true}]),
{http, Sock, {http_request, HttpMethod, {abs_path, Path}, _HttpVersion}} ->
Headers = getHeaders(Sock),
                        %more code

and then headers like that:

getHeaders(Sock, Headers) ->
{http, Sock, {http_header, _Num, 'Content-Length', _, Value}} ->
NewHeaders = Headers#'headers'{contentLength = Value},
getHeaders(Sock, NewHeaders);
{http, Sock, {http_header, _Num, 'Host', _, Value}} ->
NewHeaders = Headers#'headers'{host = Value},
getHeaders(Sock, NewHeaders);
{http, Sock, {http_header, _Num, 'User-Agent', _, Value}} ->
NewHeaders = Headers#'headers'{userAgent = Value},
getHeaders(Sock, NewHeaders);
 %more headers here

{http, Sock, {http_error, Error}} ->
?LOG_INFO("protocol", "http returned error with reason:~p~n", [Error]),
{http, Sock, http_eoh} ->
{tcp_closed, Sock} ->  %<a mark>
?LOG_INFO("connection", "Socket ~w closed by client", [Sock]),
_Else ->
getHeaders(Sock, Headers)

Normally it works fine, packets and headers are received from browser and
everyone is happy, but there is a case, when a browser sends a request, and
then i get "tcp_closed" in place where <a mark> is placed, in the middle of
receiving headers.

This behaviour is strange for me, because it never happens in incognito
mode. That could mean that bowsers cache is involved in the problem, but

Anyone had the same problem? Anyone could help? I would be grateful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150208/9ecdd715/attachment.htm>

More information about the erlang-questions mailing list