diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_req.erl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl index b13da50..8f0a04b 100644 --- a/src/cowboy_req.erl +++ b/src/cowboy_req.erl @@ -686,7 +686,9 @@ reply(Status, Headers, Body, Req=#http_req{ resp_state=RespState, resp_headers=RespHeaders}) when RespState =:= waiting; RespState =:= waiting_stream -> HTTP11Headers = if - Transport =/= cowboy_spdy, Version =:= 'HTTP/1.1' -> + Transport =/= cowboy_spdy, Version =:= 'HTTP/1.0', Connection =:= keepalive -> + [{<<"connection">>, atom_to_connection(Connection)}]; + Transport =/= cowboy_spdy, Version =:= 'HTTP/1.1', Connection =:= close -> [{<<"connection">>, atom_to_connection(Connection)}]; true -> [] @@ -988,13 +990,20 @@ chunked_response(Status, Headers, Req=#http_req{ when RespState =:= waiting; RespState =:= waiting_stream -> RespConn = response_connection(Headers, Connection), HTTP11Headers = if + Version =:= 'HTTP/1.0', Connection =:= keepalive -> + [{<<"connection">>, atom_to_connection(Connection)}]; Version =:= 'HTTP/1.0' -> []; true -> MaybeTE = if RespState =:= waiting_stream -> []; true -> [{<<"transfer-encoding">>, <<"chunked">>}] end, - [{<<"connection">>, atom_to_connection(Connection)}|MaybeTE] + if + Connection =:= close -> + [{<<"connection">>, atom_to_connection(Connection)}|MaybeTE]; + true -> + MaybeTE + end end, RespState2 = if Version =:= 'HTTP/1.1', RespState =:= 'waiting' -> chunks; |