aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-02-12 17:15:11 +0100
committerLoïc Hoguin <[email protected]>2013-02-12 17:15:11 +0100
commit20329a6e9e4adccb4bd3f9c3be0306aca469e3e6 (patch)
treedca521b968e2b928facc1dbb439ba9ca69917749
parent75b8849b475d74764205caa3a8a543a6dd003585 (diff)
downloadcowboy-20329a6e9e4adccb4bd3f9c3be0306aca469e3e6.tar.gz
cowboy-20329a6e9e4adccb4bd3f9c3be0306aca469e3e6.tar.bz2
cowboy-20329a6e9e4adccb4bd3f9c3be0306aca469e3e6.zip
Fix connection state being ignored for unknown length streaming
-rw-r--r--src/cowboy_req.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index d416916..0c4969d 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -911,7 +911,6 @@ reply(Status, Headers, Body, Req=#http_req{
version=Version, connection=Connection,
method=Method, resp_compress=Compress,
resp_state=waiting, resp_headers=RespHeaders}) ->
- RespConn = response_connection(Headers, Connection),
HTTP11Headers = case Version of
{1, 1} -> [{<<"connection">>, atom_to_connection(Connection)}];
_ -> []
@@ -919,18 +918,20 @@ reply(Status, Headers, Body, Req=#http_req{
case Body of
BodyFun when is_function(BodyFun) ->
%% We stream the response body until we close the connection.
+ RespConn = close,
{RespType, Req2} = response(Status, Headers, RespHeaders, [
{<<"connection">>, <<"close">>},
{<<"date">>, cowboy_clock:rfc1123()},
{<<"server">>, <<"Cowboy">>},
{<<"transfer-encoding">>, <<"identity">>}
- ], <<>>, Req#http_req{connection=close}),
+ ], <<>>, Req),
if RespType =/= hook, Method =/= <<"HEAD">> ->
BodyFun(Socket, Transport);
true -> ok
end;
{ContentLength, BodyFun} ->
%% We stream the response body for ContentLength bytes.
+ RespConn = response_connection(Headers, Connection),
{RespType, Req2} = response(Status, Headers, RespHeaders, [
{<<"content-length">>, integer_to_list(ContentLength)},
{<<"date">>, cowboy_clock:rfc1123()},
@@ -941,9 +942,11 @@ reply(Status, Headers, Body, Req=#http_req{
true -> ok
end;
_ when Compress ->
+ RespConn = response_connection(Headers, Connection),
Req2 = reply_may_compress(Status, Headers, Body, Req,
RespHeaders, HTTP11Headers, Method);
_ ->
+ RespConn = response_connection(Headers, Connection),
Req2 = reply_no_compress(Status, Headers, Body, Req,
RespHeaders, HTTP11Headers, Method, iolist_size(Body))
end,