Update documentation. (#73)

* Update documentation.

Synchronize goals section between README and rustdoc, and add two goals
(blocking API; no unsafe) that were mentioned elsewhere in the README.

Add error handling to examples for the module and for the Response
object.

And a section on synthetic errors to the top-level module documentation.

* Add back missing close brace.

* Add main function that returns Result.

* Add links to send_bytes and send_form.

* Document chunked encoding for send.

* Use a larger vec of bytes for send.
This commit is contained in:
Jacob Hoffman-Andrews
2020-06-21 00:55:50 -07:00
committed by GitHub
parent 7adbd57308
commit fdc1f37662
4 changed files with 71 additions and 31 deletions

View File

@@ -214,16 +214,19 @@ impl Request {
/// Send data from a reader.
///
/// The `Content-Length` header is not set because we can't know the length of the reader.
/// This uses [chunked transfer encoding](https://tools.ietf.org/html/rfc7230#section-4.1).
/// The caller is responsible for setting the Transfer-Encoding: chunked header.
///
/// The input from the reader is buffered into chunks of size 16,384, the max size of a TLS fragment.
///
/// ```
/// use std::io::Cursor;
///
/// let text = "Hello there!\n";
/// let read = Cursor::new(text.to_string().into_bytes());
/// let read = Cursor::new(vec![0x20; 100_000]);
///
/// let resp = ureq::post("/somewhere")
/// let resp = ureq::post("http://localhost/example-upload")
/// .set("Content-Type", "text/plain")
/// .set("Transfer-Encoding", "chunked")
/// .send(read);
/// ```
pub fn send(&mut self, reader: impl Read + 'static) -> Response {