This also reverts a change to send_body that was originally added to
return the number of bytes written. It's no longer needed now that we
check the size of the reader in advance.
Fixes#76.
This removes the necessity to take the result of Response::into_json and
having to convert it into a struct by using serde_json::from_value
This adds no new dependencies since serde_json already depends on serde.
Users of ureq will have to include `serde_derive` either by importing it
directly or by using serde with the `derive` feature, unless they want to
manually implement `Deserialize` on their structs.
This implementation improves over chunked_transfer's Encoder + io::copy
with the following performance optimizations:
1) It avoid copying memory
2) chunked_transfer's Encoder issues 4 separate write() per chunk.
This is costly overhead. Instead, we do a single write() per chunk
The measured benefit on a Linux machine is a 50% reduction in CPU usage
on a https connection.
This is not a perfect solution. It works as long as we are not sending
any body bytes. We discover the error first when attempting to read
the response status line. That means we discover the error after
sending body bytes. To be able to re-send the body, we would need to
introduce a buffer to be able to replay the body on the next
request. We don't currently do that.