diff --git a/Cargo.toml b/Cargo.toml index 860b2a8dca..9a41922bf6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ futures-util = { version = "0.3", default-features = false } http = "0.2" http-body = "=1.0.0-rc.2" pin-project-lite = "0.2.4" -tokio = { version = "1.13", features = ["sync"] } # Optional @@ -36,6 +35,7 @@ httparse = { version = "1.8", optional = true } httpdate = { version = "1.0", optional = true } itoa = { version = "1", optional = true } libc = { version = "0.2", optional = true } +tokio = { version = "1", features = ["sync"], optional = true } tracing = { version = "0.1", default-features = false, features = ["std"], optional = true } want = { version = "0.3", optional = true } @@ -74,13 +74,16 @@ full = [ ] # HTTP versions -http1 = ["dep:httparse", "dep:itoa"] -http2 = ["dep:h2"] +http1 = ["upgrade", "dep:httparse", "dep:itoa"] +http2 = ["upgrade", "dep:h2"] # Client/Server client = ["dep:want"] server = ["dep:httpdate"] +# HTTP Upgrades +upgrade = ["dep:tokio"] + # C-API support (currently unstable (no semver)) ffi = ["dep:libc", "dep:http-body-util"] diff --git a/src/lib.rs b/src/lib.rs index 0d1db8320a..c0ee66be35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,8 +49,10 @@ //! - `http2`: Enables HTTP/2 support. //! - `client`: Enables the HTTP `client`. //! - `server`: Enables the HTTP `server`. +//! - `upgrade`: Enables [HTTP Upgrades]. //! //! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section +//! [Http Upgrades]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism //! //! # Unstable Features //! hyper includes a set of unstable optional features that can be enabled through the use of a @@ -93,7 +95,6 @@ pub mod ext; mod mock; pub mod rt; pub mod service; -pub mod upgrade; #[cfg(feature = "ffi")] #[cfg_attr(docsrs, doc(cfg(all(feature = "ffi", hyper_unstable_ffi))))] @@ -115,3 +116,9 @@ cfg_feature! { pub mod server; } + +cfg_feature! { + #![feature = "upgrade"] + + pub mod upgrade; +}