chore: add feature flag to support more than one version

This commit is contained in:
Luis Moreno 2023-12-05 14:06:04 -04:00
parent 06d0601678
commit 2b6cfb9391
26 changed files with 104 additions and 37 deletions

View File

@ -51,4 +51,4 @@ awc = { path = "awc" }
# actix-server = { path = "../actix-net/actix-server" } # actix-server = { path = "../actix-net/actix-server" }
# Added for testing purpose while https://github.com/actix/actix-net/pull/508 is released # Added for testing purpose while https://github.com/actix/actix-net/pull/508 is released
actix-tls = { git = "https://github.com/actix/actix-net", rev = "522a2f63b2a1ce426574d046704e537ee730a9ec" } actix-tls = { git = "https://github.com/actix/actix-net", rev = "1945fa06755555dfd96eb1de5b02d6ee40a81f22" }

View File

@ -3,8 +3,8 @@
## Unreleased ## Unreleased
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.
- Updated `actix-tls` dependency to `4`. - Updated `actix-tls` dependency to `3.2`.
- Updated `http` dependency to `1`. - Added feature `http-1` for support to `http` crate version `1`.
## 3.1.0 ## 3.1.0

View File

@ -28,10 +28,13 @@ default = []
# openssl # openssl
openssl = ["tls-openssl", "awc/openssl"] openssl = ["tls-openssl", "awc/openssl"]
# use http crate v1
http-1 = ["dep:http-1", "awc/http-1"]
[dependencies] [dependencies]
actix-service = "2" actix-service = "2"
actix-codec = "0.5" actix-codec = "0.5"
actix-tls = "4" actix-tls = "3.1.1"
actix-utils = "3" actix-utils = "3"
actix-rt = "2.2" actix-rt = "2.2"
actix-server = "2" actix-server = "2"
@ -39,7 +42,8 @@ awc = { version = "3", default-features = false }
bytes = "1" bytes = "1"
futures-core = { version = "0.3.17", default-features = false } futures-core = { version = "0.3.17", default-features = false }
http = "1" http = "0.2"
http-1 = { version = "1", optional = true, package = "http" }
log = "0.4" log = "0.4"
socket2 = "0.5" socket2 = "0.5"
serde = "1" serde = "1"

View File

@ -10,6 +10,9 @@
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
extern crate tls_openssl as openssl; extern crate tls_openssl as openssl;
#[cfg(feature = "http-1")]
extern crate http_1 as http;
use std::{net, thread, time::Duration}; use std::{net, thread, time::Duration};
use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_codec::{AsyncRead, AsyncWrite, Framed};

View File

@ -7,7 +7,8 @@
- Updated `zstd` dependency to `0.13`. - Updated `zstd` dependency to `0.13`.
- Updated `http` dependency to `1`. - Updated `http` dependency to `1`.
- Updated `h2` dependency to `0.4`. - Updated `h2` dependency to `0.4`.
- Updated `actix-tls` dependency to `4`. - Updated `actix-tls` dependency to `3.2`.
- Added feature `http-1` for support to `http` crate version `1`.
### Fixed ### Fixed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-http" name = "actix-http"
version = "3.4.0" version = "3.5.0"
authors = [ authors = [
"Nikolay Kim <fafhrd91@gmail.com>", "Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>", "Rob Ede <robjtede@icloud.com>",
@ -33,6 +33,9 @@ default = []
# HTTP/2 protocol support # HTTP/2 protocol support
http2 = ["h2"] http2 = ["h2"]
# use http crate v1
http-1 = ["dep:http-1", "dep:h2-0_4"]
# WebSocket protocol implementation # WebSocket protocol implementation
ws = [ ws = [
"local-channel", "local-channel",
@ -75,7 +78,8 @@ bytestring = "1"
derive_more = "0.99.5" derive_more = "0.99.5"
encoding_rs = "0.8" encoding_rs = "0.8"
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] } futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
http = "1" http = "0.2"
http-1 = {version = "1", optional = true, package = "http" }
httparse = "1.5.1" httparse = "1.5.1"
httpdate = "1.0.1" httpdate = "1.0.1"
itoa = "1" itoa = "1"
@ -89,7 +93,8 @@ tokio-util = { version = "0.7", features = ["io", "codec"] }
tracing = { version = "0.1.30", default-features = false, features = ["log"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] }
# http2 # http2
h2 = { version = "0.4", optional = true } h2 = { version = "0.3", optional = true }
h2-0_4 = { package = "h2", version = "0.4", optional = true }
# websockets # websockets
local-channel = { version = "0.1", optional = true } local-channel = { version = "0.1", optional = true }
@ -98,7 +103,7 @@ rand = { version = "0.8", optional = true }
sha1 = { version = "0.10", optional = true } sha1 = { version = "0.10", optional = true }
# openssl/rustls # openssl/rustls
actix-tls = { version = "4", default-features = false, optional = true } actix-tls = { version = "3.1.1", default-features = false, optional = true }
# compress-* # compress-*
brotli = { version = "3.3.3", optional = true } brotli = { version = "3.3.3", optional = true }
@ -108,7 +113,7 @@ zstd = { version = "0.13", optional = true }
[dev-dependencies] [dev-dependencies]
actix-http-test = { version = "3", features = ["openssl"] } actix-http-test = { version = "3", features = ["openssl"] }
actix-server = "2" actix-server = "2"
actix-tls = { version = "4", features = ["openssl"] } actix-tls = { version = "3.1.1", features = ["openssl"] }
actix-web = "4" actix-web = "4"
async-stream = "0.3" async-stream = "0.3"

View File

@ -6,6 +6,9 @@ use derive_more::{Display, Error, From};
pub use http::Error as HttpError; pub use http::Error as HttpError;
use http::{uri::InvalidUri, StatusCode}; use http::{uri::InvalidUri, StatusCode};
#[cfg(feature = "http-1")]
use h2_0_4 as h2;
use crate::{body::BoxBody, Response}; use crate::{body::BoxBody, Response};
pub struct Error { pub struct Error {
@ -274,7 +277,7 @@ pub enum PayloadError {
/// HTTP/2 payload error. /// HTTP/2 payload error.
#[cfg(feature = "http2")] #[cfg(feature = "http2")]
#[display(fmt = "{}", _0)] #[display(fmt = "{}", _0)]
Http2Payload(::h2::Error), Http2Payload(h2::Error),
/// Generic I/O error. /// Generic I/O error.
#[display(fmt = "{}", _0)] #[display(fmt = "{}", _0)]
@ -297,8 +300,8 @@ impl std::error::Error for PayloadError {
} }
#[cfg(feature = "http2")] #[cfg(feature = "http2")]
impl From<::h2::Error> for PayloadError { impl From<h2::Error> for PayloadError {
fn from(err: ::h2::Error) -> Self { fn from(err: h2::Error) -> Self {
PayloadError::Http2Payload(err) PayloadError::Http2Payload(err)
} }
} }

View File

@ -15,6 +15,9 @@ use actix_service::Service;
use actix_utils::future::poll_fn; use actix_utils::future::poll_fn;
use bytes::{Bytes, BytesMut}; use bytes::{Bytes, BytesMut};
use futures_core::ready; use futures_core::ready;
#[cfg(feature = "http-1")]
use h2_0_4 as h2;
use h2::{ use h2::{
server::{Connection, SendResponse}, server::{Connection, SendResponse},
Ping, PingPong, Ping, PingPong,

View File

@ -1,4 +1,6 @@
//! HTTP/2 protocol. //! HTTP/2 protocol.
#[cfg(feature = "http-1")]
use h2_0_4 as h2;
use std::{ use std::{
future::Future, future::Future,

View File

@ -28,6 +28,9 @@
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "http-1")]
extern crate http_1 as http;
pub use ::http::{uri, uri::Uri, Method, StatusCode, Version}; pub use ::http::{uri, uri::Uri, Method, StatusCode, Version};
pub mod body; pub mod body;

View File

@ -10,6 +10,9 @@ use pin_project_lite::pin_project;
use crate::error::PayloadError; use crate::error::PayloadError;
#[cfg(feature = "http-1")]
use h2_0_4 as h2;
/// A boxed payload stream. /// A boxed payload stream.
pub type BoxedPayloadStream = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>; pub type BoxedPayloadStream = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>;
@ -54,8 +57,8 @@ impl<S> From<crate::h2::Payload> for Payload<S> {
} }
#[cfg(feature = "http2")] #[cfg(feature = "http2")]
impl<S> From<::h2::RecvStream> for Payload<S> { impl<S> From<h2::RecvStream> for Payload<S> {
fn from(stream: ::h2::RecvStream) -> Self { fn from(stream: h2::RecvStream) -> Self {
Payload::H2 { Payload::H2 {
payload: crate::h2::Payload::new(stream), payload: crate::h2::Payload::new(stream),
} }

View File

@ -3,9 +3,7 @@
## Unreleased ## Unreleased
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.
- Added `http-1` feature for support to `http` v1.
### Changed
- Updated `http` dependency to `1`.
## 0.5.1 ## 0.5.1

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-router" name = "actix-router"
version = "0.5.1" version = "0.5.2"
authors = [ authors = [
"Nikolay Kim <fafhrd91@gmail.com>", "Nikolay Kim <fafhrd91@gmail.com>",
"Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>", "Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>",
@ -19,16 +19,20 @@ path = "src/lib.rs"
[features] [features]
default = ["http"] default = ["http"]
# use http v1
http-1 = ["dep:http-1"]
[dependencies] [dependencies]
bytestring = ">=0.1.5, <2" bytestring = ">=0.1.5, <2"
http = { version = "1", optional = true } http = { version = "0.2", optional = true }
http-1 = { package = "http", version = "1", optional = true }
regex = "1.5" regex = "1.5"
serde = "1" serde = "1"
tracing = { version = "0.1.30", default-features = false, features = ["log"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] }
[dev-dependencies] [dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] } criterion = { version = "0.5", features = ["html_reports"] }
http = "1" http = "0.2"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
percent-encoding = "2.1" percent-encoding = "2.1"

View File

@ -15,10 +15,10 @@ mod resource;
mod resource_path; mod resource_path;
mod router; mod router;
#[cfg(feature = "http")] #[cfg(any(feature = "http", feature = "http-1"))]
mod url; mod url;
#[cfg(feature = "http")] #[cfg(any(feature = "http", feature = "http-1"))]
pub use self::url::Url; pub use self::url::Url;
pub use self::{ pub use self::{
de::PathDeserializer, de::PathDeserializer,

View File

@ -1,5 +1,8 @@
use crate::{Quoter, ResourcePath}; use crate::{Quoter, ResourcePath};
#[cfg(feature = "http-1")]
use http_1 as http;
thread_local! { thread_local! {
static DEFAULT_QUOTER: Quoter = Quoter::new(b"", b"%/+"); static DEFAULT_QUOTER: Quoter = Quoter::new(b"", b"%/+");
} }

View File

@ -6,7 +6,8 @@
- Updated `zstd` dependency to `0.13`. - Updated `zstd` dependency to `0.13`.
- Compression middleware now prefers brotli over zstd over gzip. - Compression middleware now prefers brotli over zstd over gzip.
- Updated `actix-tls` dependency to `4`. - Updated `actix-tls` dependency to `3.2`.
- Added `http-1` feature for support to `http` crate version `1`.
### Fixed ### Fixed

View File

@ -49,6 +49,11 @@ secure-cookies = ["cookies", "cookie/secure"]
http2 = ["actix-http/http2"] http2 = ["actix-http/http2"]
http-1 = [
"actix-http/http-1",
"actix-router/http-1"
]
# TLS via OpenSSL # TLS via OpenSSL
openssl = ["http2", "actix-http/openssl", "actix-tls/accept", "actix-tls/openssl"] openssl = ["http2", "actix-http/openssl", "actix-tls/accept", "actix-tls/openssl"]
@ -73,10 +78,10 @@ actix-rt = { version = "2.6", default-features = false }
actix-server = "2" actix-server = "2"
actix-service = "2" actix-service = "2"
actix-utils = "3" actix-utils = "3"
actix-tls = { version = "4.0", default-features = false, optional = true } actix-tls = { version = "3.1.1", default-features = false, optional = true }
actix-http = { version = "3.4", features = ["ws"] } actix-http = { version = "3.4", features = ["ws"] }
actix-router = "0.5" actix-router = "0.5.2"
actix-web-codegen = { version = "4.2", optional = true } actix-web-codegen = { version = "4.2", optional = true }
ahash = "0.8" ahash = "0.8"

View File

@ -4,9 +4,8 @@
- Update `trust-dns-resolver` dependency to `0.23`. - Update `trust-dns-resolver` dependency to `0.23`.
- Updated `zstd` dependency to `0.13`. - Updated `zstd` dependency to `0.13`.
- Updated `http` dependency to `1`. - Updated `actix-tls` dependency to `3.2`.
- Updated `h2` dependency to `0.4`. - Added feature `http-1` for support to `http` crate version `1`.
- Updated `actix-tls` dependency to `4`.
## 3.2.0 ## 3.2.0

View File

@ -21,7 +21,7 @@ path = "src/lib.rs"
[package.metadata.docs.rs] [package.metadata.docs.rs]
# features that docs.rs will build with # features that docs.rs will build with
features = ["openssl", "rustls-0_20", "rustls-0_21", "compress-brotli", "compress-gzip", "compress-zstd", "cookies"] features = ["openssl", "rustls-0_20", "rustls-0_21", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "http-0", "http-1"]
[features] [features]
default = ["compress-brotli", "compress-gzip", "compress-zstd", "cookies"] default = ["compress-brotli", "compress-gzip", "compress-zstd", "cookies"]
@ -58,12 +58,18 @@ __compress = []
# DO NOT enable this over any internet use case. # DO NOT enable this over any internet use case.
dangerous-h2c = [] dangerous-h2c = []
http-1 = [
"dep:http-1",
"actix-http/http-1",
"dep:h2-0_4",
]
[dependencies] [dependencies]
actix-codec = "0.5" actix-codec = "0.5"
actix-service = "2" actix-service = "2"
actix-http = { version = "3.4", features = ["http2", "ws"] } actix-http = { version = "3.5", features = ["http2", "ws"] }
actix-rt = { version = "2.1", default-features = false } actix-rt = { version = "2.1", default-features = false }
actix-tls = { version = "4.0", features = ["connect", "uri"] } actix-tls = { version = "3.1.1", features = ["connect", "uri"] }
actix-utils = "3" actix-utils = "3"
base64 = "0.21" base64 = "0.21"
@ -72,8 +78,10 @@ cfg-if = "1"
derive_more = "0.99.5" derive_more = "0.99.5"
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] } futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
futures-util = { version = "0.3.17", default-features = false, features = ["alloc", "sink"] } futures-util = { version = "0.3.17", default-features = false, features = ["alloc", "sink"] }
h2 = "0.4" h2 = "0.3"
http = "1" h2-0_4 = { version = "0.4", package = "h2", optional = true }
http = "0.2"
http-1 = { package = "http", version = "1", optional = true }
itoa = "1" itoa = "1"
log =" 0.4" log =" 0.4"
mime = "0.3" mime = "0.3"
@ -94,11 +102,11 @@ tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true, featu
trust-dns-resolver = { version = "0.23", optional = true } trust-dns-resolver = { version = "0.23", optional = true }
[dev-dependencies] [dev-dependencies]
actix-http = { version = "3.4", features = ["openssl"] } actix-http = { version = "3.5", features = ["openssl"] }
actix-http-test = { version = "3", features = ["openssl"] } actix-http-test = { version = "3", features = ["openssl"] }
actix-server = "2" actix-server = "2"
actix-test = { version = "0.1", features = ["openssl", "rustls-0_21"] } actix-test = { version = "0.1", features = ["openssl", "rustls-0_21"] }
actix-tls = { version = "4", features = ["openssl", "rustls-0_21"] } actix-tls = { version = "3.1.1", features = ["openssl", "rustls-0_21"] }
actix-utils = "3" actix-utils = "3"
actix-web = { version = "4", features = ["openssl"] } actix-web = { version = "4", features = ["openssl"] }

View File

@ -9,6 +9,9 @@ use actix_rt::net::{ActixStream, TcpStream};
use actix_service::{boxed, Service}; use actix_service::{boxed, Service};
use base64::prelude::*; use base64::prelude::*;
#[cfg(feature = "http-1")]
use http_1 as http;
use crate::{ use crate::{
client::{ client::{
ClientConfig, ConnectInfo, Connector, ConnectorService, TcpConnectError, TcpConnection, ClientConfig, ConnectInfo, Connector, ConnectorService, TcpConnectError, TcpConnection,

View File

@ -11,6 +11,9 @@ use actix_http::{body::MessageBody, h1::ClientCodec, Payload, RequestHeadType, R
use actix_rt::task::JoinHandle; use actix_rt::task::JoinHandle;
use bytes::Bytes; use bytes::Bytes;
use futures_core::future::LocalBoxFuture; use futures_core::future::LocalBoxFuture;
#[cfg(feature = "http-1")]
use http_1 as http;
use h2::client::SendRequest; use h2::client::SendRequest;
use super::{error::SendRequestError, h1proto, h2proto, pool::Acquired}; use super::{error::SendRequestError, h1proto, h2proto, pool::Acquired};

View File

@ -8,6 +8,9 @@ use std::{
time::Duration, time::Duration,
}; };
#[cfg(feature = "http-1")]
use http_1 as http;
use actix_http::Protocol; use actix_http::Protocol;
use actix_rt::{ use actix_rt::{
net::{ActixStream, TcpStream}, net::{ActixStream, TcpStream},

View File

@ -4,6 +4,8 @@ use actix_http::error::{HttpError, ParseError};
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
use actix_tls::accept::openssl::reexports::Error as OpensslError; use actix_tls::accept::openssl::reexports::Error as OpensslError;
use derive_more::{Display, From}; use derive_more::{Display, From};
#[cfg(feature = "http-1")]
use http_1 as http;
use crate::BoxError; use crate::BoxError;

View File

@ -7,6 +7,7 @@ use actix_http::{
}; };
use actix_utils::future::poll_fn; use actix_utils::future::poll_fn;
use bytes::Bytes; use bytes::Bytes;
use h2::{ use h2::{
client::{Builder, Connection, SendRequest}, client::{Builder, Connection, SendRequest},
SendStream, SendStream,
@ -16,6 +17,9 @@ use http::{
request::Request, request::Request,
Method, Version, Method, Version,
}; };
#[cfg(feature = "http-1")]
use http_1 as http;
use log::trace; use log::trace;
use super::{ use super::{

View File

@ -19,7 +19,11 @@ use actix_rt::time::{sleep, Sleep};
use actix_service::Service; use actix_service::Service;
use futures_core::future::LocalBoxFuture; use futures_core::future::LocalBoxFuture;
use futures_util::FutureExt as _; use futures_util::FutureExt as _;
#[cfg(feature = "http-1")]
use http_1 as http;
use http::uri::Authority; use http::uri::Authority;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::sync::{OwnedSemaphorePermit, Semaphore}; use tokio::sync::{OwnedSemaphorePermit, Semaphore};

View File

@ -112,6 +112,9 @@
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "http-1")]
extern crate h2_0_4 as h2;
pub use actix_http::body; pub use actix_http::body;
#[cfg(feature = "cookies")] #[cfg(feature = "cookies")]
pub use cookie; pub use cookie;