Handle un-expected closing of pipelined connections better.

If during a pipelined connection, server closes its socket,
but http client has more requests to send, ibrowse will
detect that when it sends next request and throw
{error, connection_closing}.

Handle that error better, by closing the socket explicitly
and retrying the pipelined request that failed.

COUCHDB-2833
diff --git a/src/couch_replicator_httpc.erl b/src/couch_replicator_httpc.erl
index 9a10bdb..8b34e0e 100644
--- a/src/couch_replicator_httpc.erl
+++ b/src/couch_replicator_httpc.erl
@@ -106,6 +106,14 @@
 process_response({error, sel_conn_closed}, _Worker, HttpDb, Params, _Cb) ->
     throw({retry, HttpDb, Params});
 
+%% This clause handles un-expected connection closing during pipelined requests.
+%% For example, if server responds to a request, sets Connection: close header
+%% and closes the socket, ibrowse will detect that error when it sends
+%% next request.
+process_response({error, connection_closing}, Worker, HttpDb, Params, _Cb)->
+    ibrowse_http_client:stop(Worker),
+    throw({retry, HttpDb, Params});
+
 process_response({error, {'EXIT',{normal,_}}}, _Worker, HttpDb, Params, _Cb) ->
     % ibrowse worker terminated because remote peer closed the socket
     % -> not an error