Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CAE36E49A for ; Thu, 6 Dec 2012 21:06:56 +0000 (UTC) Received: (qmail 74340 invoked by uid 500); 6 Dec 2012 21:06:55 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 74171 invoked by uid 500); 6 Dec 2012 21:06:55 -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 73643 invoked by uid 99); 6 Dec 2012 21:06:54 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2012 21:06:54 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B76B681CC0E; Thu, 6 Dec 2012 21:06:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jan@apache.org To: commits@couchdb.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [18/27] git commit: Add couch_httpd_misc_handlers:handle_file_req Message-Id: <20121206210654.B76B681CC0E@tyr.zones.apache.org> Date: Thu, 6 Dec 2012 21:06:54 +0000 (UTC) Add couch_httpd_misc_handlers:handle_file_req This can be used to serve up files like /crossdomain.xml from a CouchDB instance. For example, you could add: [httpd_global_handlers] crossdomain.xml = {couch_httpd_misc_handlers, handle_file_req, "/usr/share/couchdb/www/crossdomain.xml" } To your local.ini to serve up crossdomain.xml. Closes #4 Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/2774531f Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/2774531f Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/2774531f Branch: refs/heads/1597-update-erlang-oauth-1-3-0 Commit: 2774531ff2946c0155dc6cb2af153e6378c41963 Parents: c6252d6 Author: Joel Reed Authored: Mon Jan 31 09:25:02 2011 -0500 Committer: Jan Lehnardt Committed: Wed Nov 14 20:47:37 2012 +0100 ---------------------------------------------------------------------- src/couchdb/couch_httpd_misc_handlers.erl | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/2774531f/src/couchdb/couch_httpd_misc_handlers.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl index 2150bea..c884271 100644 --- a/src/couchdb/couch_httpd_misc_handlers.erl +++ b/src/couchdb/couch_httpd_misc_handlers.erl @@ -57,6 +57,12 @@ handle_favicon_req(#httpd{method='GET'}=Req, DocumentRoot) -> handle_favicon_req(Req, _) -> send_method_not_allowed(Req, "GET,HEAD"). +handle_file_req(#httpd{method='GET'}=Req, Document) -> + couch_httpd:serve_file(Req, filename:basename(Document), filename:dirname(Document)); + +handle_file_req(Req, _) -> + send_method_not_allowed(Req, "GET,HEAD"). + handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) -> "/" ++ UrlPath = couch_httpd:path(Req), case couch_httpd:partition(UrlPath) of