couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [03/11] chttpd commit: updated refs/heads/master to 238b8c4
Date Wed, 12 Aug 2015 15:54:27 GMT
Derive HandlerKey from path_parts

This is a preparation for introducing `before_request` hook.

Plugin might want to manipulate Path in order to affect handler selection.
Therefore HandlerKey calculation has to happen after
`chttpd_plugin:before_request` and it should be based on the value
returned from that call.

HandlerKey was constructed using `mochiweb_util:partition(Path, "/")`.
We change the logic to use first part of path_parts field of #httpd{}
record.


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

Branch: refs/heads/master
Commit: 8d0fe1c7129a27c4b82f2cd3aa2b498bc36dba25
Parents: f42f96c
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Fri Jun 19 14:12:33 2015 -0700
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Tue Aug 11 09:10:13 2015 -0700

----------------------------------------------------------------------
 src/chttpd.erl | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/8d0fe1c7/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index b6b30de..d1e07e9 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -149,8 +149,6 @@ handle_request_int(MochiReq) ->
     % removed, but URL quoting left intact
     RawUri = MochiReq:get(raw_path),
     {"/" ++ Path, _, _} = mochiweb_util:urlsplit_path(RawUri),
-    {HandlerKeyStr, _, _} = mochiweb_util:partition(Path, "/"),
-    HandlerKey = ?l2b(HandlerKeyStr),
 
     Peer = MochiReq:get(peer),
     LogForClosedSocket = io_lib:format("mochiweb_recv_error for ~s - ~p ~s", [
@@ -199,6 +197,12 @@ handle_request_int(MochiReq) ->
                 || Part <- string:tokens(Path, "/")]
     },
 
+    HandlerKey =
+        case HttpReq#httpd.path_parts of
+            [] -> <<>>;
+            [Key|_] -> ?l2b(quote(Key))
+        end,
+
     % put small token on heap to keep requests synced to backend calls
     erlang:put(nonce, couch_util:to_hex(crypto:rand_bytes(5))),
 


Mime
View raw message