You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2012/12/04 21:43:49 UTC

[29/44] git commit: refactor is_preflight_request() for clarity

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/1368-fix-multipart-header-parts
Commit: f976cfef52450a3c6c6ffd5049f5805037f874da
Parents: eccc28b
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Nov 8 22:19:27 2012 +0100
Committer: Jan Lehnardt <ja...@apache.org>
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