couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iil...@apache.org
Subject [5/6] chttpd commit: updated refs/heads/master to ab299eb
Date Tue, 15 Mar 2016 17:45:29 GMT
Introduce chttpd_plugin:before_response/4 EPI hook

COUCHDB-2966


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/3d6f2818
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/3d6f2818
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/3d6f2818

Branch: refs/heads/master
Commit: 3d6f28189014fcc372930024a173fed3cb028899
Parents: 34bd294
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Tue Mar 8 10:24:49 2016 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Tue Mar 15 10:43:56 2016 -0700

----------------------------------------------------------------------
 src/chttpd.erl        | 8 +++++---
 src/chttpd_plugin.erl | 8 +++++++-
 2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/3d6f2818/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index f653a3d..6ca1258 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -1066,9 +1066,11 @@ basic_headers(Req, Headers0) ->
         ++ couch_httpd_auth:cookie_auth_header(Req, Headers0),
     chttpd_cors:headers(Req, Headers).
 
-handle_response(Req, Code, Headers, Args, Type) ->
-    couch_stats:increment_counter([couchdb, httpd_status_codes, Code]),
-    respond_(Req, Code, Headers, Args, Type).
+handle_response(Req0, Code0, Headers0, Args0, Type) ->
+    {ok, {Req1, Code1, Headers1, Args1}} =
+        chttpd_plugin:before_response(Req0, Code0, Headers0, Args0),
+    couch_stats:increment_counter([couchdb, httpd_status_codes, Code1]),
+    respond_(Req1, Code1, Headers1, Args1, Type).
 
 respond_(#httpd{mochi_req = MochiReq}, Code, Headers, _Args, start_response) ->
     MochiReq:start_response({Code, Headers});

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/3d6f2818/src/chttpd_plugin.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_plugin.erl b/src/chttpd_plugin.erl
index 711d0a9..7286b28 100644
--- a/src/chttpd_plugin.erl
+++ b/src/chttpd_plugin.erl
@@ -15,7 +15,8 @@
 -export([
     before_request/1,
     after_request/2,
-    handle_error/1
+    handle_error/1,
+    before_response/4
 ]).
 
 -define(SERVICE_ID, chttpd).
@@ -38,6 +39,11 @@ handle_error(Error) ->
     [Error1] = with_pipe(handle_error, [Error]),
     Error1.
 
+before_response(HttpReq0, Code0, Headers0, Value0) ->
+    [HttpReq, Code, Headers, Value] =
+        with_pipe(before_response, [HttpReq0, Code0, Headers0, Value0]),
+    {ok, {HttpReq, Code, Headers, Value}}.
+
 %% ------------------------------------------------------------------
 %% Internal Function Definitions
 %% ------------------------------------------------------------------


Mime
View raw message