1 // Copyright (c) 2023 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 //! [Http/2 Protocol] Implementation.
15 //!
16 //! [Http/2 Protocol]: https://httpwg.org/specs/rfc9113.html
17 //! # Introduction
18 //! The performance of applications using the Hypertext Transfer Protocol
19 //! ([HTTP]) is linked to how each version of HTTP uses the underlying
20 //! transport, and the conditions under which the transport operates.
21 //!
22 //! Making multiple concurrent requests can reduce latency and improve
23 //! application performance. HTTP/1.0 allowed only one request to be outstanding
24 //! at a time on a given [TCP] connection. [HTTP/1.1] added request pipelining,
25 //! but this only partially addressed request concurrency and still suffers from
26 //! application-layer head-of-line blocking. Therefore, HTTP/1.0 and HTTP/1.1
27 //! clients use multiple connections to a server to make concurrent requests.
28 //!
29 //! Furthermore, HTTP fields are often repetitive and verbose, causing
30 //! unnecessary network traffic as well as causing the initial TCP congestion
31 //! window to quickly fill. This can result in excessive latency when multiple
32 //! requests are made on a new TCP connection.
33 //!
34 //! HTTP/2 addresses these issues by defining an optimized mapping of HTTP's
35 //! semantics to an underlying connection. Specifically, it allows interleaving
36 //! of messages on the same connection and uses an efficient coding for HTTP
37 //! fields. It also allows prioritization of requests, letting more important
38 //! requests complete more quickly, further improving performance.
39 //!
40 //! The resulting protocol is more friendly to the network because fewer TCP
41 //! connections can be used in comparison to HTTP/1.x. This means less
42 //! competition with other flows and longer-lived connections, which in turn
43 //! lead to better utilization of available network capacity. Note, however,
44 //! that TCP head-of-line blocking is not addressed by this protocol.
45 //!
46 //! Finally, HTTP/2 also enables more efficient processing of messages through
47 //! use of binary message framing.
48 //!
49 //! [HTTP]: https://www.rfc-editor.org/rfc/rfc9110.html
50 //! [HTTP/1.1]: https://www.rfc-editor.org/rfc/rfc9112.html
51 //! [TCP]: https://www.rfc-editor.org/rfc/rfc793.html
52 
53 mod decoder;
54 mod encoder;
55 mod error;
56 mod frame;
57 mod hpack;
58 mod parts;
59 mod pseudo;
60 
61 pub use decoder::{FrameDecoder, FrameKind, Frames, FramesIntoIter};
62 pub use encoder::FrameEncoder;
63 pub use error::{ErrorCode, H2Error};
64 pub use frame::{
65     Data, Frame, FrameFlags, Goaway, Headers, Payload, Ping, RstStream, Setting, Settings,
66     SettingsBuilder, WindowUpdate,
67 };
68 pub(crate) use hpack::{HpackDecoder, HpackEncoder};
69 pub use parts::Parts;
70 pub use pseudo::PseudoHeaders;
71