`RequestBuilder::headers` will always overwrite any existing header with
the same name, but will now correctly append extra values from the *new*
header map.
Closes#407
The need to clone a request or builder may arise when repeating a
request multiple times. This can be either because:
* The Request object is consumed by Client::execute
* The request might need to be retried later
* A complex request needs to be repeated with slightly different
parameters, such as in the Partial-Content scheme which allows seeking
through the content of large object over HTTP by performing multiple
HTTP GET requests.
To make this easier, it would be nice if Request and RequestBuilder
were to implement the Clone trait. However, this is not possible because
a body might be set that is a stream which can not be cloned. To get
around this, I added a try_clone function that fails if the body is not
clonable.
An alternative solution would be to add a type parameter to Request for
the body so a conditional implementation for Clone can be added.
This means that `build` cannot possibly panic anymore due to being
called multiple times. This is a breaking change as it breaks the
behaviour of builder methods called without assigning to a new variable
or chaining. It's rather easy to fix those usages, as they won't
compile anymore and can be fixed by assigning a result.
Additionally, this change reduces the size of `RequestBuilder`,
although this likely isn't all that meaningful, as usually there
is no reason to store builders in structures.