2020-10-30 03:19:56 +01:00
|
|
|
//! HTTP primitives for the Actix ecosystem.
|
2021-02-13 16:08:43 +01:00
|
|
|
//!
|
|
|
|
//! ## Crate Features
|
2021-06-19 21:21:13 +02:00
|
|
|
//! | Feature | Functionality |
|
|
|
|
//! | ------------------- | ------------------------------------------- |
|
2022-02-15 21:49:10 +01:00
|
|
|
//! | `http2` | HTTP/2 support via [h2]. |
|
2021-06-19 21:21:13 +02:00
|
|
|
//! | `openssl` | TLS support via [OpenSSL]. |
|
|
|
|
//! | `rustls` | TLS support via [rustls]. |
|
|
|
|
//! | `compress-brotli` | Payload compression support: Brotli. |
|
|
|
|
//! | `compress-gzip` | Payload compression support: Deflate, Gzip. |
|
|
|
|
//! | `compress-zstd` | Payload compression support: Zstd. |
|
|
|
|
//! | `trust-dns` | Use [trust-dns] as the client DNS resolver. |
|
2021-02-13 16:08:43 +01:00
|
|
|
//!
|
2022-02-15 21:49:10 +01:00
|
|
|
//! [h2]: https://crates.io/crates/h2
|
2021-02-13 16:08:43 +01:00
|
|
|
//! [OpenSSL]: https://crates.io/crates/openssl
|
|
|
|
//! [rustls]: https://crates.io/crates/rustls
|
|
|
|
//! [trust-dns]: https://crates.io/crates/trust-dns
|
2020-09-10 15:46:35 +02:00
|
|
|
|
2021-12-08 07:09:56 +01:00
|
|
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
|
|
|
#![warn(future_incompatible)]
|
2019-04-08 08:06:21 +02:00
|
|
|
#![allow(
|
|
|
|
clippy::type_complexity,
|
2019-07-17 09:55:44 +02:00
|
|
|
clippy::too_many_arguments,
|
2023-01-01 21:56:27 +01:00
|
|
|
clippy::borrow_interior_mutable_const,
|
|
|
|
clippy::uninlined_format_args
|
2019-04-08 08:06:21 +02:00
|
|
|
)]
|
2020-10-30 03:19:56 +01:00
|
|
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
|
|
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
2023-02-26 22:55:25 +01:00
|
|
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
2019-03-26 19:54:35 +01:00
|
|
|
|
2023-07-17 03:38:12 +02:00
|
|
|
pub use ::http::{uri, uri::Uri, Method, StatusCode, Version};
|
2021-12-22 08:16:07 +01:00
|
|
|
|
2019-03-26 19:54:35 +01:00
|
|
|
pub mod body;
|
|
|
|
mod builder;
|
|
|
|
mod config;
|
2022-01-31 18:30:34 +01:00
|
|
|
mod date;
|
2021-06-19 21:21:13 +02:00
|
|
|
#[cfg(feature = "__compress")]
|
2019-03-26 23:14:32 +01:00
|
|
|
pub mod encoding;
|
2021-12-19 18:05:27 +01:00
|
|
|
pub mod error;
|
2019-03-26 19:54:35 +01:00
|
|
|
mod extensions;
|
2021-12-19 18:05:27 +01:00
|
|
|
pub mod h1;
|
2022-01-31 22:22:23 +01:00
|
|
|
#[cfg(feature = "http2")]
|
2021-12-19 18:05:27 +01:00
|
|
|
pub mod h2;
|
2021-04-19 04:29:38 +02:00
|
|
|
pub mod header;
|
2019-03-26 19:54:35 +01:00
|
|
|
mod helpers;
|
2021-02-11 23:58:35 +01:00
|
|
|
mod http_message;
|
2022-01-31 18:30:34 +01:00
|
|
|
mod keep_alive;
|
2019-03-26 19:54:35 +01:00
|
|
|
mod message;
|
2022-01-31 18:30:34 +01:00
|
|
|
#[cfg(test)]
|
|
|
|
mod notify_on_drop;
|
2019-03-26 19:54:35 +01:00
|
|
|
mod payload;
|
2021-12-19 18:05:27 +01:00
|
|
|
mod requests;
|
|
|
|
mod responses;
|
2019-03-26 19:54:35 +01:00
|
|
|
mod service;
|
2019-11-18 13:42:27 +01:00
|
|
|
pub mod test;
|
2022-01-31 22:22:23 +01:00
|
|
|
#[cfg(feature = "ws")]
|
2019-11-18 13:42:27 +01:00
|
|
|
pub mod ws;
|
2019-03-26 19:54:35 +01:00
|
|
|
|
2021-12-24 18:47:47 +01:00
|
|
|
#[allow(deprecated)]
|
2023-07-17 03:38:12 +02:00
|
|
|
pub use self::payload::PayloadStream;
|
2023-08-27 01:07:11 +02:00
|
|
|
#[cfg(any(feature = "openssl", feature = "rustls-0_20", feature = "rustls-0_21"))]
|
2022-06-27 04:57:21 +02:00
|
|
|
pub use self::service::TlsAcceptorConfig;
|
2023-07-17 03:38:12 +02:00
|
|
|
pub use self::{
|
|
|
|
builder::HttpServiceBuilder,
|
|
|
|
config::ServiceConfig,
|
|
|
|
error::Error,
|
|
|
|
extensions::Extensions,
|
|
|
|
header::ContentEncoding,
|
|
|
|
http_message::HttpMessage,
|
|
|
|
keep_alive::KeepAlive,
|
|
|
|
message::{ConnectionType, Message},
|
|
|
|
payload::{BoxedPayloadStream, Payload},
|
|
|
|
requests::{Request, RequestHead, RequestHeadType},
|
|
|
|
responses::{Response, ResponseBuilder, ResponseHead},
|
|
|
|
service::HttpService,
|
|
|
|
};
|
2019-03-26 19:54:35 +01:00
|
|
|
|
2021-01-06 19:58:24 +01:00
|
|
|
/// A major HTTP protocol version.
|
2019-12-02 12:33:11 +01:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
2021-01-06 19:58:24 +01:00
|
|
|
#[non_exhaustive]
|
2019-12-02 12:33:11 +01:00
|
|
|
pub enum Protocol {
|
|
|
|
Http1,
|
|
|
|
Http2,
|
2021-01-06 19:58:24 +01:00
|
|
|
Http3,
|
2019-12-02 12:33:11 +01:00
|
|
|
}
|
2020-10-30 03:03:26 +01:00
|
|
|
|
|
|
|
type ConnectCallback<IO> = dyn Fn(&IO, &mut Extensions);
|
2021-01-06 19:43:52 +01:00
|
|
|
|
|
|
|
/// Container for data that extract with ConnectCallback.
|
2021-01-06 19:52:06 +01:00
|
|
|
///
|
|
|
|
/// # Implementation Details
|
|
|
|
/// Uses Option to reduce necessary allocations when merging with request extensions.
|
2021-10-19 02:32:58 +02:00
|
|
|
#[derive(Default)]
|
2021-01-06 19:43:52 +01:00
|
|
|
pub(crate) struct OnConnectData(Option<Extensions>);
|
|
|
|
|
|
|
|
impl OnConnectData {
|
2021-01-06 19:52:06 +01:00
|
|
|
/// Construct by calling the on-connect callback with the underlying transport I/O.
|
2021-12-08 07:01:11 +01:00
|
|
|
pub(crate) fn from_io<T>(io: &T, on_connect_ext: Option<&ConnectCallback<T>>) -> Self {
|
2021-01-06 19:43:52 +01:00
|
|
|
let ext = on_connect_ext.map(|handler| {
|
2021-12-07 18:23:34 +01:00
|
|
|
let mut extensions = Extensions::default();
|
2021-01-06 19:43:52 +01:00
|
|
|
handler(io, &mut extensions);
|
|
|
|
extensions
|
|
|
|
});
|
|
|
|
|
|
|
|
Self(ext)
|
|
|
|
}
|
|
|
|
}
|