mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Added warn compile options. Fixed compile warnings.
This commit is contained in:
parent
3181382d72
commit
73c718dcb5
3 changed files with 19 additions and 14 deletions
3
Makefile
3
Makefile
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
PROJECT = cowboy
|
PROJECT = cowboy
|
||||||
RANCH_VSN = 0.6.1
|
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
|
DEPS_DIR ?= $(CURDIR)/deps
|
||||||
export DEPS_DIR
|
export DEPS_DIR
|
||||||
|
|
|
@ -53,9 +53,9 @@
|
||||||
execute(Req, Env) ->
|
execute(Req, Env) ->
|
||||||
{_, Handler} = lists:keyfind(handler, 1, Env),
|
{_, Handler} = lists:keyfind(handler, 1, Env),
|
||||||
{_, HandlerOpts} = lists:keyfind(handler_opts, 1, Env),
|
{_, HandlerOpts} = lists:keyfind(handler_opts, 1, Env),
|
||||||
case lists:keyfind(loop_max_buffer, 1, Env) of
|
MaxBuffer = case lists:keyfind(loop_max_buffer, 1, Env) of
|
||||||
false -> MaxBuffer = 5000, ok;
|
false -> 5000;
|
||||||
{_, MaxBuffer} -> ok
|
{_, MaxBuffer0} -> MaxBuffer0
|
||||||
end,
|
end,
|
||||||
handler_init(Req, #state{env=Env, loop_max_buffer=MaxBuffer},
|
handler_init(Req, #state{env=Env, loop_max_buffer=MaxBuffer},
|
||||||
Handler, HandlerOpts).
|
Handler, HandlerOpts).
|
||||||
|
|
|
@ -623,12 +623,13 @@ init_stream(TransferDecode, TransferState, ContentDecode, Req) ->
|
||||||
| {done, Req} | {error, atom()} when Req::req().
|
| {done, Req} | {error, atom()} when Req::req().
|
||||||
stream_body(Req=#http_req{body_state=waiting,
|
stream_body(Req=#http_req{body_state=waiting,
|
||||||
version=Version, transport=Transport, socket=Socket}) ->
|
version=Version, transport=Transport, socket=Socket}) ->
|
||||||
case parse_header(<<"expect">>, Req) of
|
{ok, ExpectHeader, Req1} = parse_header(<<"expect">>, Req),
|
||||||
{ok, [<<"100-continue">>], Req1} ->
|
case ExpectHeader of
|
||||||
|
[<<"100-continue">>] ->
|
||||||
HTTPVer = cowboy_http:version_to_binary(Version),
|
HTTPVer = cowboy_http:version_to_binary(Version),
|
||||||
Transport:send(Socket,
|
Transport:send(Socket,
|
||||||
<< HTTPVer/binary, " ", (status(100))/binary, "\r\n\r\n" >>);
|
<< HTTPVer/binary, " ", (status(100))/binary, "\r\n\r\n" >>);
|
||||||
{ok, undefined, Req1} ->
|
undefined ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
case parse_header(<<"transfer-encoding">>, Req1) of
|
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)}];
|
{1, 1} -> [{<<"connection">>, atom_to_connection(Connection)}];
|
||||||
_ -> []
|
_ -> []
|
||||||
end,
|
end,
|
||||||
case Body of
|
Req3 = case Body of
|
||||||
BodyFun when is_function(BodyFun) ->
|
BodyFun when is_function(BodyFun) ->
|
||||||
%% We stream the response body until we close the connection.
|
%% We stream the response body until we close the connection.
|
||||||
RespConn = close,
|
RespConn = close,
|
||||||
|
@ -934,7 +935,8 @@ reply(Status, Headers, Body, Req=#http_req{
|
||||||
if RespType =/= hook, Method =/= <<"HEAD">> ->
|
if RespType =/= hook, Method =/= <<"HEAD">> ->
|
||||||
BodyFun(Socket, Transport);
|
BodyFun(Socket, Transport);
|
||||||
true -> ok
|
true -> ok
|
||||||
end;
|
end,
|
||||||
|
Req2#http_req{connection=RespConn};
|
||||||
{ContentLength, BodyFun} ->
|
{ContentLength, BodyFun} ->
|
||||||
%% We stream the response body for ContentLength bytes.
|
%% We stream the response body for ContentLength bytes.
|
||||||
RespConn = response_connection(Headers, Connection),
|
RespConn = response_connection(Headers, Connection),
|
||||||
|
@ -946,18 +948,20 @@ reply(Status, Headers, Body, Req=#http_req{
|
||||||
if RespType =/= hook, Method =/= <<"HEAD">> ->
|
if RespType =/= hook, Method =/= <<"HEAD">> ->
|
||||||
BodyFun(Socket, Transport);
|
BodyFun(Socket, Transport);
|
||||||
true -> ok
|
true -> ok
|
||||||
end;
|
end,
|
||||||
|
Req2#http_req{connection=RespConn};
|
||||||
_ when Compress ->
|
_ when Compress ->
|
||||||
RespConn = response_connection(Headers, Connection),
|
RespConn = response_connection(Headers, Connection),
|
||||||
Req2 = reply_may_compress(Status, Headers, Body, Req,
|
Req2 = reply_may_compress(Status, Headers, Body, Req,
|
||||||
RespHeaders, HTTP11Headers, Method);
|
RespHeaders, HTTP11Headers, Method),
|
||||||
|
Req2#http_req{connection=RespConn};
|
||||||
_ ->
|
_ ->
|
||||||
RespConn = response_connection(Headers, Connection),
|
RespConn = response_connection(Headers, Connection),
|
||||||
Req2 = reply_no_compress(Status, Headers, Body, Req,
|
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,
|
end,
|
||||||
{ok, Req2#http_req{connection=RespConn, resp_state=done,
|
{ok, Req3#http_req{resp_state=done,resp_headers=[], resp_body= <<>>}}.
|
||||||
resp_headers=[], resp_body= <<>>}}.
|
|
||||||
|
|
||||||
reply_may_compress(Status, Headers, Body, Req,
|
reply_may_compress(Status, Headers, Body, Req,
|
||||||
RespHeaders, HTTP11Headers, Method) ->
|
RespHeaders, HTTP11Headers, Method) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue