You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2011/05/23 23:26:00 UTC
svn commit: r1126759 - /couchdb/branches/1.1.x/src/couchdb/couch_httpd.erl
Author: rnewson
Date: Mon May 23 21:26:00 2011
New Revision: 1126759
URL: http://svn.apache.org/viewvc?rev=1126759&view=rev
Log:
Fix authentication. Jquery append "*.*" to accept by
default so if we test text/html first it will alway be true. Then test
first if application/json was given and then test if text/html then
others.
Backported from trunk (related to COUCHDB-1175).
Modified:
couchdb/branches/1.1.x/src/couchdb/couch_httpd.erl
Modified: couchdb/branches/1.1.x/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_httpd.erl?rev=1126759&r1=1126758&r2=1126759&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_httpd.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_httpd.erl Mon May 23 21:26:00 2011
@@ -764,24 +764,29 @@ error_headers(#httpd{mochi_req=MochiReq}
% send the browser popup header no matter what if we are require_valid_user
{Code, [{"WWW-Authenticate", "Basic realm=\"server\""}]};
_False ->
- case MochiReq:accepts_content_type("text/html") of
- false ->
- {Code, []};
+ case MochiReq:accepts_content_type("application/json") of
true ->
- % Redirect to the path the user requested, not
- % the one that is used internally.
- UrlReturnRaw = case MochiReq:get_header_value("x-couchdb-vhost-path") of
- undefined ->
- MochiReq:get(path);
- VHostPath ->
- VHostPath
- end,
- RedirectLocation = lists:flatten([
- AuthRedirect,
- "?return=", couch_util:url_encode(UrlReturnRaw),
- "&reason=", couch_util:url_encode(ReasonStr)
- ]),
- {302, [{"Location", absolute_uri(Req, RedirectLocation)}]}
+ {Code, []};
+ false ->
+ case MochiReq:accepts_content_type("text/html") of
+ true ->
+ % Redirect to the path the user requested, not
+ % the one that is used internally.
+ UrlReturnRaw = case MochiReq:get_header_value("x-couchdb-vhost-path") of
+ undefined ->
+ MochiReq:get(path);
+ VHostPath ->
+ VHostPath
+ end,
+ RedirectLocation = lists:flatten([
+ AuthRedirect,
+ "?return=", couch_util:url_encode(UrlReturnRaw),
+ "&reason=", couch_util:url_encode(ReasonStr)
+ ]),
+ {302, [{"Location", absolute_uri(Req, RedirectLocation)}]};
+ false ->
+ {Code, []}
+ end
end
end
end;