aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-02-22 13:57:11 +0100
committerLoïc Hoguin <[email protected]>2013-02-22 13:57:11 +0100
commitf7fa4016ec71e3b406be3fec73f63aa01b370eef (patch)
tree06db546859287826c95caabbe460eaa363fcd007
parent3181382d72d0f7be681e150cfa2baabec5c2861b (diff)
parent73c718dcb5a5c7bff77f34bc22f3b68f4683bec3 (diff)
downloadcowboy-f7fa4016ec71e3b406be3fec73f63aa01b370eef.tar.gz
cowboy-f7fa4016ec71e3b406be3fec73f63aa01b370eef.tar.bz2
cowboy-f7fa4016ec71e3b406be3fec73f63aa01b370eef.zip
Merge branch 'fix-warnings' of git://github.com/Egobrain/cowboy
-rw-r--r--Makefile3
-rw-r--r--src/cowboy_handler.erl6
-rw-r--r--src/cowboy_req.erl24
3 files changed, 19 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index d04758c..2349caa 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,8 @@
PROJECT = cowboy
RANCH_VSN = 0.6.1
-ERLC_OPTS = -Werror +debug_info +warn_export_all # +bin_opt_info +warn_missing_spec
+ERLC_OPTS = -Werror +debug_info +warn_export_all +warn_export_vars \
+ +warn_shadow_vars +warn_obsolete_guard # +bin_opt_info +warn_missing_spec
DEPS_DIR ?= $(CURDIR)/deps
export DEPS_DIR
diff --git a/src/cowboy_handler.erl b/src/cowboy_handler.erl
index fd2e085..ab09a97 100644
--- a/src/cowboy_handler.erl
+++ b/src/cowboy_handler.erl
@@ -53,9 +53,9 @@
execute(Req, Env) ->
{_, Handler} = lists:keyfind(handler, 1, Env),
{_, HandlerOpts} = lists:keyfind(handler_opts, 1, Env),
- case lists:keyfind(loop_max_buffer, 1, Env) of
- false -> MaxBuffer = 5000, ok;
- {_, MaxBuffer} -> ok
+ MaxBuffer = case lists:keyfind(loop_max_buffer, 1, Env) of
+ false -> 5000;
+ {_, MaxBuffer0} -> MaxBuffer0
end,
handler_init(Req, #state{env=Env, loop_max_buffer=MaxBuffer},
Handler, HandlerOpts).
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index 8c9a618..79aa44d 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -623,12 +623,13 @@ init_stream(TransferDecode, TransferState, ContentDecode, Req) ->
| {done, Req} | {error, atom()} when Req::req().
stream_body(Req=#http_req{body_state=waiting,
version=Version, transport=Transport, socket=Socket}) ->
- case parse_header(<<"expect">>, Req) of
- {ok, [<<"100-continue">>], Req1} ->
+ {ok, ExpectHeader, Req1} = parse_header(<<"expect">>, Req),
+ case ExpectHeader of
+ [<<"100-continue">>] ->
HTTPVer = cowboy_http:version_to_binary(Version),
Transport:send(Socket,
<< HTTPVer/binary, " ", (status(100))/binary, "\r\n\r\n" >>);
- {ok, undefined, Req1} ->
+ undefined ->
ok
end,
case parse_header(<<"transfer-encoding">>, Req1) of
@@ -921,7 +922,7 @@ reply(Status, Headers, Body, Req=#http_req{
{1, 1} -> [{<<"connection">>, atom_to_connection(Connection)}];
_ -> []
end,
- case Body of
+ Req3 = case Body of
BodyFun when is_function(BodyFun) ->
%% We stream the response body until we close the connection.
RespConn = close,
@@ -934,7 +935,8 @@ reply(Status, Headers, Body, Req=#http_req{
if RespType =/= hook, Method =/= <<"HEAD">> ->
BodyFun(Socket, Transport);
true -> ok
- end;
+ end,
+ Req2#http_req{connection=RespConn};
{ContentLength, BodyFun} ->
%% We stream the response body for ContentLength bytes.
RespConn = response_connection(Headers, Connection),
@@ -946,18 +948,20 @@ reply(Status, Headers, Body, Req=#http_req{
if RespType =/= hook, Method =/= <<"HEAD">> ->
BodyFun(Socket, Transport);
true -> ok
- end;
+ end,
+ Req2#http_req{connection=RespConn};
_ when Compress ->
RespConn = response_connection(Headers, Connection),
Req2 = reply_may_compress(Status, Headers, Body, Req,
- RespHeaders, HTTP11Headers, Method);
+ RespHeaders, HTTP11Headers, Method),
+ Req2#http_req{connection=RespConn};
_ ->
RespConn = response_connection(Headers, Connection),
Req2 = reply_no_compress(Status, Headers, Body, Req,
- RespHeaders, HTTP11Headers, Method, iolist_size(Body))
+ RespHeaders, HTTP11Headers, Method, iolist_size(Body)),
+ Req2#http_req{connection=RespConn}
end,
- {ok, Req2#http_req{connection=RespConn, resp_state=done,
- resp_headers=[], resp_body= <<>>}}.
+ {ok, Req3#http_req{resp_state=done,resp_headers=[], resp_body= <<>>}}.
reply_may_compress(Status, Headers, Body, Req,
RespHeaders, HTTP11Headers, Method) ->