Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6A0DBD786 for ; Thu, 8 Nov 2012 23:24:57 +0000 (UTC) Received: (qmail 6398 invoked by uid 500); 8 Nov 2012 23:24:56 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 6360 invoked by uid 500); 8 Nov 2012 23:24:56 -0000 Mailing-List: contact dev-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 dev@couchdb.apache.org Received: (qmail 6337 invoked by uid 99); 8 Nov 2012 23:24:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Nov 2012 23:24:56 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bchesneau@gmail.com designates 209.85.223.180 as permitted sender) Received: from [209.85.223.180] (HELO mail-ie0-f180.google.com) (209.85.223.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Nov 2012 23:24:48 +0000 Received: by mail-ie0-f180.google.com with SMTP id e10so4887827iej.11 for ; Thu, 08 Nov 2012 15:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=O9iIRGKOB1a6oKeSDMXc7We0I3xfXV/+6i23XhugpL4=; b=p9hEAFIhOmgjQJNg6cqc2ZFNitUbzVvEK+QVvGZ7r6ek1ogJmXRAbKwCj+sdfRxP/j WXuxxq249mESLn9WacmQZR8hFfqFBkqjCnfoydPIZWo/Mw/dG0NcKABSJ9lZMJCEXkGf UrKoBzH0KVxliAXqujQ6W+O5lqSE+pIn+Dnqj4AQH+xTmX/OLRq8sX92wS0v8cE8KIiq aH37PKWO4EWmdBWDiVdAOFPZm386NBX3SPJ6+GS8mBjwmUSs5Ynw9MX4KDewvByy6y5+ 2yUhw3FOb2dmGJ1t2PwI0GkASl6miPbANYJRrye4jAa3hge7lpzQQZawdv8kvCstkxTU t25A== MIME-Version: 1.0 Received: by 10.50.100.229 with SMTP id fb5mr126773igb.11.1352417068304; Thu, 08 Nov 2012 15:24:28 -0800 (PST) Received: by 10.64.77.196 with HTTP; Thu, 8 Nov 2012 15:24:28 -0800 (PST) In-Reply-To: References: <20121108224411.75A5545CE3@tyr.zones.apache.org> Date: Fri, 9 Nov 2012 00:24:28 +0100 Message-ID: Subject: Re: [15/15] git commit: refactor is_preflight_request() for clarity From: Benoit Chesneau To: "dev@couchdb.apache.org" Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org forget the enable_cors() blah On Fri, Nov 9, 2012 at 12:23 AM, Benoit Chesneau wrote: > Hrm I don't find it more clear... Now you have to look at 2 places to > know what this true or false is about. the case was enough. Also why > not reusing the enable_cors() new fonction ? > > On Thu, Nov 8, 2012 at 11:44 PM, wrote: >> refactor is_preflight_request() for clarity >> >> >> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo >> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f976cfef >> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f976cfef >> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f976cfef >> >> Branch: refs/heads/431-feature_cors >> Commit: f976cfef52450a3c6c6ffd5049f5805037f874da >> Parents: eccc28b >> Author: Jan Lehnardt >> Authored: Thu Nov 8 22:19:27 2012 +0100 >> Committer: Jan Lehnardt >> Committed: Thu Nov 8 23:37:33 2012 +0100 >> >> ---------------------------------------------------------------------- >> src/couchdb/couch_httpd_cors.erl | 22 +++++++++++----------- >> 1 files changed, 11 insertions(+), 11 deletions(-) >> ---------------------------------------------------------------------- >> >> >> http://git-wip-us.apache.org/repos/asf/couchdb/blob/f976cfef/src/couchdb/couch_httpd_cors.erl >> ---------------------------------------------------------------------- >> diff --git a/src/couchdb/couch_httpd_cors.erl b/src/couchdb/couch_httpd_cors.erl >> index 6f501cc..a783ae6 100644 >> --- a/src/couchdb/couch_httpd_cors.erl >> +++ b/src/couchdb/couch_httpd_cors.erl >> @@ -32,20 +32,20 @@ >> >> is_preflight_request(#httpd{method=Method}=Req) when Method /= 'OPTIONS' -> >> Req; >> -is_preflight_request(#httpd{mochi_req=MochiReq}=Req) -> >> - case get_bool_config("httpd", "enable_cors", false) of >> - true -> >> - case preflight_request(MochiReq) of >> - {ok, PreflightHeaders} -> >> - send_preflight_response(Req, PreflightHeaders); >> - _ -> >> - Req >> - end; >> - false -> >> +is_preflight_request(Req) -> >> + EnableCors = get_bool_config("httpd", "enable_cors", false), >> + is_preflight_request(Req, EnableCors). >> + >> +is_preflight_request(Req, false) -> >> + Req; >> +is_preflight_request(#httpd{mochi_req=MochiReq}=Req, true) -> >> + case preflight_request(MochiReq) of >> + {ok, PreflightHeaders} -> >> + send_preflight_response(Req, PreflightHeaders); >> + _ -> >> Req >> end. >> >> - >> cors_headers(#httpd{mochi_req=MochiReq}) -> >> Host = couch_httpd_vhost:host(MochiReq), >> case get_bool_config("httpd", "enable_cors", false) of >>