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 //! # Introduction 17 //! The performance of applications using the Hypertext Transfer Protocol 18 //! ([HTTP]) is linked to how each version of HTTP uses the underlying 19 //! transport, and the conditions under which the transport operates. 20 //! 21 //! Making multiple concurrent requests can reduce latency and improve 22 //! application performance. HTTP/1.0 allowed only one request to be outstanding 23 //! at a time on a given [TCP] connection. [HTTP/1.1] added request pipelining, 24 //! but this only partially addressed request concurrency and still suffers from 25 //! application-layer head-of-line blocking. Therefore, HTTP/1.0 and HTTP/1.1 26 //! clients use multiple connections to a server to make concurrent requests. 27 //! 28 //! Furthermore, HTTP fields are often repetitive and verbose, causing 29 //! unnecessary network traffic as well as causing the initial TCP congestion 30 //! window to quickly fill. This can result in excessive latency when multiple 31 //! requests are made on a new TCP connection. 32 //! 33 //! HTTP/2 addresses these issues by defining an optimized mapping of HTTP's 34 //! semantics to an underlying connection. Specifically, it allows interleaving 35 //! of messages on the same connection and uses an efficient coding for HTTP 36 //! fields. It also allows prioritization of requests, letting more important 37 //! requests complete more quickly, further improving performance. 38 //! 39 //! The resulting protocol is more friendly to the network because fewer TCP 40 //! connections can be used in comparison to HTTP/1.x. This means less 41 //! competition with other flows and longer-lived connections, which in turn 42 //! lead to better utilization of available network capacity. Note, however, 43 //! that TCP head-of-line blocking is not addressed by this protocol. 44 //! 45 //! Finally, HTTP/2 also enables more efficient processing of messages through 46 //! use of binary message framing. 47 //! 48 //! [HTTP]: https://www.rfc-editor.org/rfc/rfc9110.html 49 //! [HTTP/1.1]: https://www.rfc-editor.org/rfc/rfc9112.html 50 //! [Http/2]: https://httpwg.org/specs/rfc9113.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 60 pub use decoder::{FrameDecoder, FrameKind, Frames, FramesIntoIter}; 61 pub use encoder::FrameEncoder; 62 pub use error::{ErrorCode, H2Error}; 63 pub use frame::{ 64 Data, Frame, FrameFlags, Goaway, Headers, Payload, Ping, RstStream, Setting, Settings, 65 SettingsBuilder, StreamId, WindowUpdate, 66 }; 67 pub(crate) use hpack::{HpackDecoder, HpackEncoder}; 68 pub use parts::Parts; 69 70 pub use crate::pseudo::PseudoHeaders; 71