<div dir="ltr"><div>I've got problem with using erlang active http socket.</div><div><br></div><div>I receive msgs like that:</div><div><br></div><div>ok = inet:setopts(Sock,[{active, true}]),</div><div><span class="" style="white-space:pre">  </span>receive</div><div><span class="" style="white-space:pre">            </span>{http, Sock, {http_request, HttpMethod, {abs_path, Path}, _HttpVersion}} -></div><div><span class="" style="white-space:pre">                     </span>Headers = getHeaders(Sock),</div><div>                        %more code</div><div><br></div><div>and then headers like that:</div><div><br></div><div><div>getHeaders(Sock, Headers) -></div><div><span class="" style="white-space:pre">      </span>receive</div><div><span class="" style="white-space:pre">            </span>{http, Sock, {http_header, _Num, 'Content-Length', _, Value}} -></div><div><span class="" style="white-space:pre">                        </span>NewHeaders = Headers#'headers'{contentLength = Value},</div><div><span class="" style="white-space:pre">                     </span>getHeaders(Sock, NewHeaders);</div><div><span class="" style="white-space:pre">              </span>{http, Sock, {http_header, _Num, 'Host', _, Value}} -></div><div><span class="" style="white-space:pre">                  </span>NewHeaders = Headers#'headers'{host = Value},</div><div><span class="" style="white-space:pre">                      </span>getHeaders(Sock, NewHeaders);</div><div><span class="" style="white-space:pre">              </span>{http, Sock, {http_header, _Num, 'User-Agent', _, Value}} -></div><div><span class="" style="white-space:pre">                    </span>NewHeaders = Headers#'headers'{userAgent = Value},</div><div><span class="" style="white-space:pre">                 </span>getHeaders(Sock, NewHeaders);</div><div><span class="" style="white-space:pre">              </span></div><div><span class="" style="white-space:pre">               %more headers here</span></div><div><span class="" style="white-space:pre">               %</span></div><div><span class="" style="white-space:pre"><br></span></div><div><span class="" style="white-space:pre">         </span>{http, Sock, {http_error, Error}} -></div><div><span class="" style="white-space:pre">                    </span>?LOG_INFO("protocol", "http returned error with reason:~p~n", [Error]),</div><div><span class="" style="white-space:pre">                        </span>exit(normal);</div><div><span class="" style="white-space:pre">              </span>{http, Sock, http_eoh} -></div><div><span class="" style="white-space:pre">                       </span>Headers;</div><div><span class="" style="white-space:pre">           </span>{tcp_closed, Sock} ->  %<a mark></div><div><span class="" style="white-space:pre">                 </span>?LOG_INFO("connection", "Socket ~w closed by client", [Sock]),</div><div><span class="" style="white-space:pre">                 </span>exit(normal);</div><div><span class="" style="white-space:pre">              </span>_Else -></div><div><span class="" style="white-space:pre">                        </span>getHeaders(Sock, Headers)</div><div><span class="" style="white-space:pre">  </span>end.</div></div><div><br></div><div><br></div><div>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.</div><div><br></div><div>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?</div><div><br></div><div>Anyone had the same problem? Anyone could help? I would be grateful.</div><div><br></div></div>