summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2018-04-06 12:16:43 -0400
committerNick Vatamaniuc <nickva@users.noreply.github.com>2018-04-06 13:16:02 -0400
commita0dd94657f2f62b42fae2cdbd26b255e8fb95848 (patch)
treeb65696768d199124f5a4b99ce960e47f0fc33d60
parent0e926881c2c41a557cac035a779e2a95d13168ca (diff)
downloadcouchdb-a0dd94657f2f62b42fae2cdbd26b255e8fb95848.tar.gz
Do not drop updated httpdb record after auth headers are updated
In replicator, after client auth plugin updates headers it could also update its private context. Make sure to pass the updated httpdb record along to response processing code. For example, session plugin updates the epoch number in its context, and it needs the epoch number later in response processing to make the decision whether to refresh the cookie or not.
-rw-r--r--src/couch_replicator/src/couch_replicator_httpc.erl8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/couch_replicator/src/couch_replicator_httpc.erl b/src/couch_replicator/src/couch_replicator_httpc.erl
index 2f865c6d2..e4cf11606 100644
--- a/src/couch_replicator/src/couch_replicator_httpc.erl
+++ b/src/couch_replicator/src/couch_replicator_httpc.erl
@@ -71,14 +71,14 @@ send_req(HttpDb, Params1, Callback) ->
[{K, ?b2l(iolist_to_binary(V))} || {K, V} <- get_value(qs, Params1, [])]),
Params = ?replace(Params2, ibrowse_options,
lists:keysort(1, get_value(ibrowse_options, Params2, []))),
- {Worker, Response} = send_ibrowse_req(HttpDb, Params),
+ {Worker, Response, HttpDb1} = send_ibrowse_req(HttpDb, Params),
Ret = try
- process_response(Response, Worker, HttpDb, Params, Callback)
+ process_response(Response, Worker, HttpDb1, Params, Callback)
catch
throw:{retry, NewHttpDb0, NewParams0} ->
{retry, NewHttpDb0, NewParams0}
after
- Pool = HttpDb#httpdb.httpc_pool,
+ Pool = HttpDb1#httpdb.httpc_pool,
case get(?STOP_HTTP_WORKER) of
stop ->
ok = stop_and_release_worker(Pool, Worker),
@@ -124,7 +124,7 @@ send_ibrowse_req(#httpdb{headers = BaseHeaders} = HttpDb0, Params) ->
backoff_before_request(Worker, HttpDb, Params),
Response = ibrowse:send_req_direct(
Worker, Url, Headers2, Method, Body, IbrowseOptions, Timeout),
- {Worker, Response}.
+ {Worker, Response, HttpDb}.
%% Stop worker, wait for it to die, then release it. Make sure it is dead before