summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2010-07-06 18:36:27 +0000
committerJohn Christopher Anderson <jchris@apache.org>2010-07-06 18:36:27 +0000
commit57c207603a0d85ecb43c81393f95d62864b4aaf1 (patch)
tree8613e777e75932855c7eac57ae951ffab6eb27f5 /src/couchdb
parent64d82c8c2b7a177b7affd552d551d24d67c92886 (diff)
dont redirect endlessly when require_valid_user=true
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@960975 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_httpd.erl21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index ef930147..079b9367 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -748,15 +748,20 @@ error_headers(#httpd{mochi_req=MochiReq}=Req, Code, ErrorStr, ReasonStr) ->
case couch_config:get("couch_httpd_auth", "authentication_redirect", nil) of
nil -> {Code, []};
AuthRedirect ->
- % if the accept header matches html, then do the redirect. else proceed as usual.
- case re:run(MochiReq:get_header_value("Accept"), "html", [{capture, none}]) of
- nomatch ->
+ case couch_config:get("couch_httpd_auth", "require_valid_user", "false") of
+ "true" ->
{Code, []};
- match ->
- AuthRedirectBin = ?l2b(AuthRedirect),
- UrlReturn = ?l2b(couch_util:url_encode(MochiReq:get(path))),
- UrlReason = ?l2b(couch_util:url_encode(ReasonStr)),
- {302, [{"Location", couch_httpd:absolute_uri(Req, <<AuthRedirectBin/binary,"?return=",UrlReturn/binary,"&reason=",UrlReason/binary>>)}]}
+ _False ->
+ % if the accept header matches html, then do the redirect. else proceed as usual.
+ case re:run(MochiReq:get_header_value("Accept"), "html", [{capture, none}]) of
+ nomatch ->
+ {Code, []};
+ match ->
+ AuthRedirectBin = ?l2b(AuthRedirect),
+ UrlReturn = ?l2b(couch_util:url_encode(MochiReq:get(path))),
+ UrlReason = ?l2b(couch_util:url_encode(ReasonStr)),
+ {302, [{"Location", couch_httpd:absolute_uri(Req, <<AuthRedirectBin/binary,"?return=",UrlReturn/binary,"&reason=",UrlReason/binary>>)}]}
+ end
end
end;
_Else ->