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:48 UTC

[17/44] git commit: refactor credentials() for clarity

refactor credentials() for clarity


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/63e93a36
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/63e93a36
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/63e93a36

Branch: refs/heads/1368-fix-multipart-header-parts
Commit: 63e93a369603efade953ee5b5be4cea69fd9d8b5
Parents: 7f4122d
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Nov 8 22:43:04 2012 +0100
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Nov 8 23:37:34 2012 +0100

----------------------------------------------------------------------
 src/couchdb/couch_httpd_cors.erl |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/63e93a36/src/couchdb/couch_httpd_cors.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_cors.erl b/src/couchdb/couch_httpd_cors.erl
index 6c3989a..e14917f 100644
--- a/src/couchdb/couch_httpd_cors.erl
+++ b/src/couchdb/couch_httpd_cors.erl
@@ -80,14 +80,16 @@ handle_cors_headers(Origin, Host, AcceptedOrigins) ->
         []
     end.
 
+
 make_cors_header(Origin, Host) ->
-    case credentials(Origin, Host) of
-    true ->
-        [{"Access-Control-Allow-Origin", Origin},
-         {"Access-Control-Allow-Credentials", "true"}];
-    false ->
-        [{"Access-Control-Allow-Origin", Origin}]
-    end.
+    Credentials = credentials(Origin, Host),
+    [{"Access-Control-Allow-Origin", Origin}]
+    ++ make_cors_header_credentials(Credentials).
+
+make_cors_header_credentials(true) ->
+    [{"Access-Control-Allow-Credentials", "true"}];
+make_cors_header_credentials(false) ->
+    [].
 
 preflight_request(MochiReq) ->
     Host = couch_httpd_vhost:host(MochiReq),