0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Do not try to keep-alive when using HTTP/1.0

This commit is contained in:
Loïc Hoguin 2012-11-27 16:15:15 +01:00
parent 8386e10dcc
commit 5bc5f56eb2

View file

@ -183,15 +183,13 @@ new(Socket, Transport, Method, Path, Query, Fragment,
method=Method, path=Path, qs=Query, fragment=Fragment, version=Version, method=Method, path=Path, qs=Query, fragment=Fragment, version=Version,
headers=Headers, host=Host, port=Port, buffer=Buffer, headers=Headers, host=Host, port=Port, buffer=Buffer,
onresponse=OnResponse}, onresponse=OnResponse},
case CanKeepalive of case CanKeepalive and (Version =:= {1, 1}) of
false -> false ->
Req#http_req{connection=close}; Req#http_req{connection=close};
true -> true ->
case lists:keyfind(<<"connection">>, 1, Headers) of case lists:keyfind(<<"connection">>, 1, Headers) of
false when Version =:= {1, 1} ->
Req; %% keepalive
false -> false ->
Req#http_req{connection=close}; Req; %% keepalive
{_, ConnectionHeader} -> {_, ConnectionHeader} ->
Tokens = parse_connection_before(ConnectionHeader, []), Tokens = parse_connection_before(ConnectionHeader, []),
Connection = connection_to_atom(Tokens), Connection = connection_to_atom(Tokens),