couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [3/15] git commit: move duplicate code into a function
Date Thu, 08 Nov 2012 22:44:11 GMT
move duplicate code into a function


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

Branch: refs/heads/431-feature_cors
Commit: 547ead072a4f6a506c9e329efbedddf06115961f
Parents: f35e537
Author: Jan Lehnardt <jan@apache.org>
Authored: Thu Nov 8 22:53:03 2012 +0100
Committer: Jan Lehnardt <jan@apache.org>
Committed: Thu Nov 8 23:37:34 2012 +0100

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


http://git-wip-us.apache.org/repos/asf/couchdb/blob/547ead07/src/couchdb/couch_httpd_cors.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_cors.erl b/src/couchdb/couch_httpd_cors.erl
index d7ffe2d..90a7543 100644
--- a/src/couchdb/couch_httpd_cors.erl
+++ b/src/couchdb/couch_httpd_cors.erl
@@ -55,7 +55,7 @@ cors_headers(MochiReq) ->
 
 cors_headers(#httpd{mochi_req=MochiReq}, true) ->
     Host = couch_httpd_vhost:host(MochiReq),
-    AcceptedOrigins = split_list(cors_config(Host, "origins", [])),
+    AcceptedOrigins = get_accepted_origins(Host),
     case MochiReq:get_header_value("Origin") of
     undefined ->
         [];
@@ -91,7 +91,7 @@ preflight_request(MochiReq) ->
         MochiReq;
 
     Origin ->
-        AcceptedOrigins = split_list(cors_config(Host, "origins", [])),
+        AcceptedOrigins = get_accepted_origins(Host),
         AcceptAll = lists:member("*", AcceptedOrigins),
 
         case {AcceptAll, AcceptedOrigins} of
@@ -210,6 +210,9 @@ get_bool_config(Section, Key, Default) ->
         false
     end.
 
+get_accepted_origins(Host) ->
+    split_list(cors_config(Host, "origins", [])).
+
 split_list(S) ->
     re:split(S, "\\s*,\\s*", [trim, {return, list}]).
 


Mime
View raw message