couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iil...@apache.org
Subject [29/50] couch-httpd commit: updated refs/heads/split_out_httpd_stack to e44a372
Date Tue, 01 Mar 2016 20:01:02 GMT
Extract maybe_abort_head_request


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/commit/f3ed8094
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/tree/f3ed8094
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/diff/f3ed8094

Branch: refs/heads/split_out_httpd_stack
Commit: f3ed8094ed9eb601ae6c7110e8af7643919b8c40
Parents: 460d75d
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Fri Feb 26 10:40:51 2016 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Tue Mar 1 08:35:08 2016 -0800

----------------------------------------------------------------------
 src/couch_httpd.erl | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/f3ed8094/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index 80f79af..c0e2338 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -120,29 +120,17 @@
     resp=nil
 }).
 
-start_response_length(#httpd{mochi_req=MochiReq}=Req, Code, Headers, Length) ->
+start_response_length(#httpd{}=Req, Code, Headers, Length) ->
     Resp = handle_response(Req, Code, Headers, Length, start_response_length),
-    case MochiReq:get(method) of
-    'HEAD' -> throw({http_head_abort, Resp});
-    _ -> ok
-    end,
-    {ok, Resp}.
+    maybe_abort_head_request(Req, Resp).
 
-start_response(#httpd{mochi_req=MochiReq}=Req, Code, Headers) ->
+start_response(#httpd{}=Req, Code, Headers) ->
     Resp = handle_response(Req, Code, Headers, undefined, start_response),
-    case MochiReq:get(method) of
-        'HEAD' -> throw({http_head_abort, Resp});
-        _ -> ok
-    end,
-    {ok, Resp}.
+    maybe_abort_head_request(Req, Resp).
 
-start_chunked_response(#httpd{mochi_req=MochiReq}=Req, Code, Headers) ->
+start_chunked_response(#httpd{}=Req, Code, Headers) ->
     Resp = handle_response(Req, Code, Headers, chunked, respond),
-    case MochiReq:get(method) of
-    'HEAD' -> throw({http_head_abort, Resp});
-    _ -> ok
-    end,
-    {ok, Resp}.
+    maybe_abort_head_request(Req, Resp).
 
 start_json_response(Req, Code) ->
     start_json_response(Req, Code, []).
@@ -951,6 +939,12 @@ maybe_log_response(Code, Body) when Code >= 400 ->
 maybe_log_response(_, _) ->
     ok.
 
+maybe_abort_head_request(#httpd{mochi_req = MochiReq}, Resp) ->
+    case MochiReq:get(method) of
+        'HEAD' -> throw({http_head_abort, Resp});
+        _ -> {ok, Resp}
+    end.
+
 %%%%%%%% module tests below %%%%%%%%
 
 -ifdef(TEST).


Mime
View raw message