|
21 | 21 | //!
|
22 | 22 | //! # How does HTTP work?
|
23 | 23 | //!
|
24 |
| -//! We couldn't possibly explain _all_ of HTTP here, as there's [5 versions](enum.Version.html) of |
25 |
| -//! the protocol now, and lots of extensions. But at its core there are only a few concepts you |
26 |
| -//! need to know about. |
| 24 | +//! We couldn't possibly explain _all_ of HTTP here: there are [5 versions](enum.Version.html) of |
| 25 | +//! the protocol now, and lots of extensions. But, at its core, there are only a few concepts you |
| 26 | +//! need to know about in order to understand what this crate does. |
27 | 27 | //!
|
28 | 28 | //! ```txt
|
29 | 29 | //! request
|
|
39 | 39 | //! does some work, and sends back a [`Response`](struct.Response.html).
|
40 | 40 | //!
|
41 | 41 | //! The `Url` works as a way to subdivide an IP address/domain into further addressable resources.
|
42 |
| -//! The `Method` indicates what kind of operation we're trying perform (get something, submit |
| 42 | +//! The `Method` indicates what kind of operation we're trying to perform (get something, submit |
43 | 43 | //! something, update something, etc.)
|
44 | 44 | //!
|
45 | 45 | //! ```txt
|
|
54 | 54 | //! ```
|
55 | 55 | //!
|
56 | 56 | //! A `Response` consists of a [`StatusCode`](enum.StatusCode.html),
|
57 |
| -//! [`Headers`](struct.Headers.html), and optional [`Body`](struct.Body.html). The client then |
| 57 | +//! [`Headers`](struct.Headers.html), and optionally a [`Body`](struct.Body.html). The client then |
58 | 58 | //! decodes the `Response`, and can then operate on it. Usually the first thing it does is check
|
59 |
| -//! the status code to see if it was successful or not, and then operates on the headers. |
| 59 | +//! the status code to see if its `Request` was successful or not, and then moves on to the information contained within the headers. |
60 | 60 | //!
|
61 | 61 | //! ```txt
|
62 | 62 | //! Response
|
|
72 | 72 | //! requests. It needs to be encoded in a specific way (all lowercase ASCII, only some special
|
73 | 73 | //! characters) so we use the [`HeaderName`](headers/struct.HeaderName.html) and
|
74 | 74 | //! [`HeaderValue`](headers/struct.HeaderValue.html) structs rather than strings to ensure that.
|
75 |
| -//! Also another interesting thing about this is that it's valid to have multiple instances of the |
76 |
| -//! same header name. Which is why `Headers` allows inserting multiple values, and always returns a |
77 |
| -//! vector of headers for each key. |
| 75 | +//! Another interesting thing about this is that it's valid to have multiple instances of the |
| 76 | +//! same header name. This is why `Headers` allows inserting multiple values, and always returns a |
| 77 | +//! [`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html) of headers for each key. |
78 | 78 | //!
|
79 | 79 | //! When reading up on HTTP you might frequently hear a lot of jargon related to ther underlying
|
80 | 80 | //! protocols. But even newer HTTP versions (`HTTP/2`, `HTTP/3`) still fundamentally use the
|
81 | 81 | //! request/response model we've described so far.
|
82 | 82 | //!
|
83 | 83 | //! # The Body Type
|
84 | 84 | //!
|
85 |
| -//! In HTTP [`Body`](struct.Body.html) types are optional. But funamentally they're streams of |
86 |
| -//! bytes with a specific encoding, also known as [`Mime` type](struct.Mime.html). The `Mime` can |
| 85 | +//! In HTTP, [`Body`](struct.Body.html) types are optional. The content of a `Body` is a stream of |
| 86 | +//! bytes with a specific encoding; this encoding is its [`Mime` type](struct.Mime.html). The `Mime` can |
87 | 87 | //! be set using the [`set_content_type`](struct.Request.html#method.set_content_type) method, and
|
88 |
| -//! there are many different `Mime` types possible. |
| 88 | +//! there are many different possible `Mime` types. |
89 | 89 | //!
|
90 | 90 | //! `http-types`' `Body` struct can take anything that implements
|
91 | 91 | //! [`AsyncBufRead`](https://docs.rs/futures/0.3.1/futures/io/trait.AsyncBufRead.html) and stream
|
92 | 92 | //! it out. Depending on the version of HTTP used, the underlying bytes will be transmitted
|
93 |
| -//! differently. But as a rule: if you know the size of the body, it's usually more efficient to |
| 93 | +//! differently. As a rule, if you know the size of the body it's usually more efficient to |
94 | 94 | //! declare it up front. But if you don't, things will still work.
|
95 | 95 |
|
96 | 96 | #![deny(missing_debug_implementations, nonstandard_style)]
|
|
0 commit comments