[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}]),
receive
{http, Sock, {http_request, HttpMethod, {abs_path, Path}, _HttpVersion}} ->
Headers = getHeaders(Sock),
                        %more code

and then headers like that:

getHeaders(Sock, Headers) ->
receive
{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]),
exit(normal);
{http, Sock, http_eoh} ->
Headers;
{tcp_closed, Sock} ->  %<a mark>
?LOG_INFO("connection", "Socket ~w closed by client", [Sock]),
exit(normal);
_Else ->
getHeaders(Sock, Headers)
end.


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
how?

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