couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [12/28] git commit: refactor credentials() for clarity
Date Sun, 11 Nov 2012 19:24:31 GMT
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/dd59ddfe
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/dd59ddfe
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/dd59ddfe

Branch: refs/heads/431-feature-cors
Commit: dd59ddfe798efe6b8aa45807302a386a36c8bf57
Parents: d19f694
Author: Jan Lehnardt <jan@apache.org>
Authored: Thu Nov 8 22:43:04 2012 +0100
Committer: Jan Lehnardt <jan@apache.org>
Committed: Sun Nov 11 16:11:15 2012 +0000

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


http://git-wip-us.apache.org/repos/asf/couchdb/blob/dd59ddfe/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),


Mime
View raw message