diff options
author | Jan Lehnardt <jan@apache.org> | 2009-10-11 05:49:19 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-10-11 05:49:19 +0000 |
commit | e3610fa481b5c506ca0b69f49a6f350fce8b3399 (patch) | |
tree | b0050828126b4bf2dda4eb1c977630787d7b0f3a /src/couchdb/couch_rep_httpc.erl | |
parent | e3507c9e1bb57986ccffc9324d99bec4d0e4cc58 (diff) |
add create_target:true option to _replicate that creates the target database
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@824029 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_rep_httpc.erl')
-rw-r--r-- | src/couchdb/couch_rep_httpc.erl | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/couchdb/couch_rep_httpc.erl b/src/couchdb/couch_rep_httpc.erl index b714be6b..ba863746 100644 --- a/src/couchdb/couch_rep_httpc.erl +++ b/src/couchdb/couch_rep_httpc.erl @@ -14,7 +14,7 @@ -include("couch_db.hrl"). -include("../ibrowse/ibrowse.hrl"). --export([db_exists/1, full_url/1, request/1, spawn_worker_process/1, +-export([db_exists/1, db_exists/2, full_url/1, request/1, spawn_worker_process/1, spawn_link_worker_process/1]). request(Req) when is_record(Req, http_db) -> @@ -59,7 +59,16 @@ do_request(Req) -> db_exists(Req) -> db_exists(Req, Req#http_db.url). +db_exists(Req, true) -> + db_exists(Req, Req#http_db.url, true); + +db_exists(Req, false) -> + db_exists(Req, Req#http_db.url, false); + db_exists(Req, CanonicalUrl) -> + db_exists(Req, CanonicalUrl, false). + +db_exists(Req, CanonicalUrl, CreateDB) -> #http_db{ auth = Auth, headers = Headers0, @@ -71,6 +80,11 @@ db_exists(Req, CanonicalUrl) -> {OAuthProps} -> [oauth_header(Url, [], head, OAuthProps) | Headers0] end, + case CreateDB of + true -> + catch ibrowse:send_req(Url, Headers, put); + _Else -> ok + end, case catch ibrowse:send_req(Url, Headers, head) of {ok, "200", _, _} -> Req#http_db{url = CanonicalUrl}; |