You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wi...@apache.org on 2020/01/10 08:13:04 UTC

[couchdb-mochiweb] 07/32: Remove compile(tuple_calls) from mochiweb_http

This is an automated email from the ASF dual-hosted git repository.

willholley pushed a commit to branch upstream-2.20.0
in repository https://gitbox.apache.org/repos/asf/couchdb-mochiweb.git

commit dc741519b5fadf8c3b6aa13ee5607dcb306e0527
Author: Bob Ippolito <bo...@redivi.com>
AuthorDate: Sat Mar 9 20:43:12 2019 +0000

    Remove compile(tuple_calls) from mochiweb_http
---
 src/mochiweb_http.erl | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/mochiweb_http.erl b/src/mochiweb_http.erl
index a4bfa9e..6854b6a 100644
--- a/src/mochiweb_http.erl
+++ b/src/mochiweb_http.erl
@@ -28,8 +28,6 @@
 -export([after_response/2, reentry/1]).
 -export([parse_range_request/1, range_skip_length/2]).
 
--compile(tuple_calls).
-
 -define(REQUEST_RECV_TIMEOUT, 300000).   %% timeout waiting for request line
 -define(HEADERS_RECV_TIMEOUT, 30000).    %% timeout waiting for headers
 
@@ -76,7 +74,7 @@ start_link(Options) ->
     ok = ensure_started(mochiweb_clock),
     mochiweb_socket_server:start_link(parse_options(Options)).
 
-ensure_started(M) ->
+ensure_started(M) when is_atom(M) ->
     case M:start() of
         {ok, _Pid} ->
             ok;
@@ -140,9 +138,9 @@ headers(Socket, Opts, Request, Headers, Body, HeaderCount) ->
         exit(normal)
     end.
 
-call_body({M, F, A}, Req) ->
+call_body({M, F, A}, Req) when is_atom(M) ->
     erlang:apply(M, F, [Req | A]);
-call_body({M, F}, Req) ->
+call_body({M, F}, Req) when is_atom(M) ->
     M:F(Req);
 call_body(Body, Req) ->
     Body(Req).
@@ -164,8 +162,8 @@ handle_invalid_msg_request(Msg, Socket, Opts, Request, RevHeaders) ->
 
 -spec handle_invalid_request(term(), term(), term(), term()) -> no_return().
 handle_invalid_request(Socket, Opts, Request, RevHeaders) ->
-    Req = new_request(Socket, Opts, Request, RevHeaders),
-    Req:respond({400, [], []}),
+    {ReqM, _} = Req = new_request(Socket, Opts, Request, RevHeaders),
+    ReqM:respond({400, [], []}, Req),
     mochiweb_socket:close(Socket),
     exit(normal).
 
@@ -173,14 +171,14 @@ new_request(Socket, Opts, Request, RevHeaders) ->
     ok = mochiweb_socket:exit_if_closed(mochiweb_socket:setopts(Socket, [{packet, raw}])),
     mochiweb:new_request({Socket, Opts, Request, lists:reverse(RevHeaders)}).
 
-after_response(Body, Req) ->
-    Socket = Req:get(socket),
-    case Req:should_close() of
+after_response(Body, {ReqM, _} = Req) ->
+    Socket = ReqM:get(socket, Req),
+    case ReqM:should_close(Req) of
         true ->
             mochiweb_socket:close(Socket),
             exit(normal);
         false ->
-            Req:cleanup(),
+            ReqM:cleanup(Req),
             erlang:garbage_collect(),
             ?MODULE:loop(Socket, mochiweb_request:get(opts, Req), Body)
     end.