Skip to main content

http_request/
lib.rs

1//! http-request
2//!
3//! An HTTP request library providing client-side HTTP request construction and response parsing.
4
5mod common;
6mod pool;
7mod protocol;
8mod request;
9mod response;
10mod tls;
11mod utils;
12
13#[cfg(test)]
14#[path = "../tests/mod.rs"]
15mod tests;
16
17pub use {request::*, response::*};
18
19pub use http_type::{
20    ACCEPT, ACCEPT_ANY, BR_BYTES, COLON_U8, CONTENT_LENGTH, CONTENT_TYPE, Compress, ContentType,
21    HOST, HTTP_BR_BYTES, HTTPS_LOWERCASE, HashMapXxHash3_64, HttpStatus, HttpUrlComponents,
22    HttpVersion, LOCATION, Method, Protocol, QUERY, RequestError, SPACE_U8, TAB_U8, USER_AGENT,
23    hash_map_xx_hash3_64,
24};
25
26pub use std::{
27    cmp,
28    collections::{HashMap, HashSet, VecDeque},
29    fmt::{self, Debug, Display, Formatter},
30    io::{self, Read, Write},
31    mem,
32    net::{Ipv4Addr, Ipv6Addr, TcpStream},
33    pin::Pin,
34    str::from_utf8,
35    string::FromUtf8Error,
36    sync::Arc,
37    task::{Context, Poll},
38    time::Duration,
39    vec::IntoIter,
40};
41
42pub use {
43    http_type::tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf},
44    rustls::{
45        ClientConfig, ClientConnection, Error, RootCertStore, StreamOwned,
46        pki_types::{InvalidDnsNameError, ServerName},
47    },
48    serde::Serialize,
49    serde_json::to_vec,
50    tokio_rustls::{TlsConnector, client::TlsStream},
51    webpki_roots::TLS_SERVER_ROOTS,
52};
53
54pub use common::*;
55pub use lombok_macros::*;
56
57pub(crate) use {pool::*, protocol::*, tls::*};
58
59use std::{
60    borrow::Cow,
61    cell::{RefCell, RefMut},
62    mem::MaybeUninit,
63    net::{SocketAddr, ToSocketAddrs},
64    slice,
65    str::from_utf8_unchecked,
66    sync::{Mutex, OnceLock},
67    thread,
68    time::Instant,
69};
70
71use {
72    bytes::Bytes,
73    core::hash::BuildHasherDefault,
74    h2::{RecvStream, client::SendRequest},
75    http::{HeaderName, HeaderValue, Request, Response, StatusCode, Uri, request::Builder},
76    http_type::{
77        BodyPart, CLOSE, COMMA_U8, CONNECT, CONNECTION, COOKIE, CookieBuilder, DEFAULT_HTTP_PATH,
78        DELETE, GET, HEAD, HTTP_VERSION_1_0, HTTP_VERSION_1_1, HTTP_VERSION_2, KEEP_ALIVE, OPTIONS,
79        PATCH, POINT_U8, POST, PUT, QUERY_U8, ROOT_PATH_U8, SET_COOKIE, TRACE, ZERO_STR_U8, tokio,
80    },
81    rustls::client::Resumption,
82    rustls_pki_types::{CertificateDer, pem::PemObject},
83    serde::de::DeserializeOwned,
84    serde_json::from_slice,
85};