From bc3b258fe7ae3ffee555a348066887dbe1bce8b6 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Thu, 15 Oct 2009 06:29:26 +0000 Subject: also fix attachment redirects git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@825407 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_rep_att.erl | 4 +--- src/couchdb/couch_rep_httpc.erl | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/couchdb/couch_rep_att.erl b/src/couchdb/couch_rep_att.erl index baeb6c65..40ca4687 100644 --- a/src/couchdb/couch_rep_att.erl +++ b/src/couchdb/couch_rep_att.erl @@ -85,10 +85,8 @@ start_http_request(Req) -> validate_headers(_Req, 200, _Headers) -> ok; validate_headers(Req, Code, Headers) when Code > 299, Code < 400 -> - %% TODO check that the qs is actually included in the Location header - %% TODO this only supports one level of redirection Url = mochiweb_headers:get_value("Location",mochiweb_headers:make(Headers)), - NewReq = Req#http_db{url=Url, resource="", qs=[]}, + NewReq = couch_rep_httpc:redirected_request(Req, Url), {ibrowse_req_id, ReqId} = couch_rep_httpc:request(NewReq), receive {ibrowse_async_headers, ReqId, NewCode, NewHeaders} -> ok = validate_headers(NewReq, list_to_integer(NewCode), NewHeaders) diff --git a/src/couchdb/couch_rep_httpc.erl b/src/couchdb/couch_rep_httpc.erl index d9e63b3b..55d8180e 100644 --- a/src/couchdb/couch_rep_httpc.erl +++ b/src/couchdb/couch_rep_httpc.erl @@ -14,8 +14,8 @@ -include("couch_db.hrl"). -include("../ibrowse/ibrowse.hrl"). --export([db_exists/1, db_exists/2, full_url/1, request/1, spawn_worker_process/1, - spawn_link_worker_process/1]). +-export([db_exists/1, db_exists/2, full_url/1, request/1, redirected_request/2, + spawn_worker_process/1, spawn_link_worker_process/1]). request(Req) when is_record(Req, http_db) -> do_request(Req). -- cgit v1.2.3