From commits-return-5611-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Wed Dec 01 17:49:39 2010 Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 21964 invoked from network); 1 Dec 2010 17:49:39 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Dec 2010 17:49:39 -0000 Received: (qmail 91556 invoked by uid 500); 1 Dec 2010 17:49:39 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 91435 invoked by uid 500); 1 Dec 2010 17:49:39 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 91428 invoked by uid 99); 1 Dec 2010 17:49:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Dec 2010 17:49:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Dec 2010 17:49:38 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2CD9123889EA; Wed, 1 Dec 2010 17:48:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1041103 - /couchdb/trunk/src/couchdb/couch_httpd.erl Date: Wed, 01 Dec 2010 17:48:07 -0000 To: commits@couchdb.apache.org From: fdmanana@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101201174807.2CD9123889EA@eris.apache.org> Author: fdmanana Date: Wed Dec 1 17:48:06 2010 New Revision: 1041103 URL: http://svn.apache.org/viewvc?rev=1041103&view=rev Log: Proper verification of the accepted content types plus some code cleaning. Modified: couchdb/trunk/src/couchdb/couch_httpd.erl Modified: couchdb/trunk/src/couchdb/couch_httpd.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=1041103&r1=1041102&r2=1041103&view=diff ============================================================================== --- couchdb/trunk/src/couchdb/couch_httpd.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd.erl Wed Dec 1 17:48:06 2010 @@ -757,31 +757,24 @@ 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 -> - % if the accept header matches html, then do the redirect. else proceed as usual. - Accepts = case MochiReq:get_header_value("Accept") of - undefined -> - % According to the HTTP 1.1 spec, if the Accept - % header is missing, it means the client accepts - % all media types. - "html"; - Else -> - Else - end, - case re:run(Accepts, "\\bhtml\\b", - [{capture, none}, caseless]) of - nomatch -> + case MochiReq:accepts_content_type("text/html") of + false -> {Code, []}; - match -> - AuthRedirectBin = ?l2b(AuthRedirect), + 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 + undefined -> + MochiReq:get(path); + VHostPath -> + VHostPath end, - UrlReturn = ?l2b(couch_util:url_encode(UrlReturnRaw)), - UrlReason = ?l2b(couch_util:url_encode(ReasonStr)), - {302, [{"Location", couch_httpd:absolute_uri(Req, <