summaryrefslogtreecommitdiff
path: root/src/chttpd.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-06-09 14:42:57 -0400
committerAdam Kocoloski <adam@cloudant.com>2010-08-12 11:18:44 -0400
commitcb6e67e0dffe925794a700e6e5149ededaa8bf7a (patch)
treed902221e75b26a9cea3e1331ceda6a10f79c1226 /src/chttpd.erl
parent4da7e07ff67f9a0e29cd09c7c91ed3606ac01bdf (diff)
cleanup of customer_name code
Diffstat (limited to 'src/chttpd.erl')
-rw-r--r--src/chttpd.erl11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/chttpd.erl b/src/chttpd.erl
index daf9b4da..1cc15d7e 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -63,9 +63,7 @@ handle_request(MochiReq) ->
% for the path, use the raw path with the query string and fragment
% removed, but URL quoting left intact
RawUri = MochiReq:get(raw_path),
- Customer = cloudant_util:customer_name(
- MochiReq:get_header_value("X-Cloudant-User"),
- MochiReq:get_header_value("Host")),
+ Customer = cloudant_util:customer_name(#httpd{mochi_req=MochiReq}),
Path = ?COUCH:db_path(RawUri, Customer),
{HandlerKey, _, _} = mochiweb_util:partition(Path, "/"),
@@ -245,7 +243,7 @@ qs(#httpd{mochi_req=MochiReq}) ->
path(#httpd{mochi_req=MochiReq}) ->
MochiReq:get(path).
-absolute_uri(#httpd{mochi_req=MochiReq}, Path) ->
+absolute_uri(#httpd{mochi_req=MochiReq} = Req, Path) ->
XHost = couch_config:get("httpd", "x_forwarded_host", "X-Forwarded-Host"),
Host = case MochiReq:get_header_value(XHost) of
undefined ->
@@ -270,10 +268,7 @@ absolute_uri(#httpd{mochi_req=MochiReq}, Path) ->
_ -> "http"
end
end,
- Customer = cloudant_util:customer_name(
- MochiReq:get_header_value("X-Cloudant-User"),
- Host),
- CustomerRegex = ["^/", Customer, "[/%2F]+"],
+ CustomerRegex = ["^/", cloudant_util:customer_name(Req), "[/%2F]+"],
NewPath = re:replace(Path, CustomerRegex, "/"),
Scheme ++ "://" ++ Host ++ NewPath.