Unknown errors on _replicate POST are 500's not 404's
COUCHDB-1788 - tolerate undefined source/target when reading _replicator docs
Use latest=true when retrieving revisions

This allows the replicator to keep up with revisions that may have
occured after missing_revs was called.

BugzID: 14241
Avoid deadlocking the httpc pool

The multipart mime parsing code was getting into a state where it would
orphan parsers that held onto pool connections. This just adds a monitor
to make sure that the parser process dies when the parent dies normally
without finishing reading the rest of the parser.

BugzID: 16751
Fix replication deadlock after HTTP retries

An HTTP failure in the open_doc_revs can lead to a replication deadlock
if the retry happens while parsing the multipart/mime response. The
UserFun callback can end up attempting to PUT a request using an
attachment reader from the failed request while the pid that invoked
open_doc_revs will never see the started_open_doc_revs message which
indicates a retry has happened.

This just spawns a middleman process so that the process that invoked
open_doc_revs can listen for the response from the user function as well
as the started_open_doc_revs message to handle retries appropriately.
Handle open_revs retries at a higher level

This patch disables the httpc client retries for the request to stream
document revisions to the replicator.  The retry logic at that level
could end up jumbling together response body data from different
requests and thoroughly confusing the multipart parser.  Moving the
retry logic up a level allows us to start fresh each time.

BugzID: 21367
Ensure the att reader learns of a Parser death
Disable automatic retries of streaming writes

An automatic retry makes no sense here, as we've already streamed part
of the response body from the GET.  Disabling the retries bubbles the
error up to run_user_fun inside open_doc_revs allows us to retry the
whole GET + PUT correctly.

BugzID: 20822
Simplify doc_streamer initialization

The unlink at the end is a noop, so we can simplify this to use
spawn_link/3 and the fully-exported function call instead of
spawn_link/1 and a closure.

BugzID: 20822
Be a bit nicer about logging
Bubble up missing_stub exceptions for proper retry

A missing_stub exception is special in that the replicator retries the
request without the atts_since optimmization.

COUCHDB-1901
Allow the use of checkpoint to be optional

A new parameter use_checkpoints which defaults to be true can be either used in the replicator section of
ini files and/or used in the replication command or doc added to the replicator db. When this option is set
to false no checkpoints are taken. It should be used with caution and only for small dbs.

BugzID:14327
configurable checkpoint interval
Include reason for replication failure in _replicator doc

closes COUCHDB-1647
Tests for replicator use_checkpoints option
don't crash if ibrowse is already started

fix #COUCHDB-1986
Support SOCKS5 protocol for replication

Using "socks5" as the protocol in the "proxy" parameter of replication
requests will cause DNS resolution and data transfer to happen via a
SOCKS5 proxy server.

COUCHDB-2025
Negotiate max uri length in response to 414's
Merge remote-tracking branch 'origin/import-master' into 1843-feature-bigcouch

Conflicts:
	Makefile.am
	src/couch_replicator_api_wrap.erl
	src/couch_replicator_manager.erl
	src/couch_replicator_utils.erl
	test/04-replication-large-atts.t
Simplify _replicator DB check

This version simply checks that the DB in question has a name that ends
in /_replicator (or is just _replicator).  It allows for the possibility
that foo/_replicator is treated as a _replicator DB.

BugzID: 23315

Conflicts:
	src/couch_replicator_manager.erl