Skip to content

Commit

Permalink
chore: add feature flag to support more than one version
Browse files Browse the repository at this point in the history
  • Loading branch information
morenol committed Dec 6, 2023
1 parent 06d0601 commit 2b6cfb9
Show file tree
Hide file tree
Showing 26 changed files with 104 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -51,4 +51,4 @@ awc = { path = "awc" }
# actix-server = { path = "../actix-net/actix-server" }

# 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" }
4 changes: 2 additions & 2 deletions actix-http-test/CHANGES.md
Expand Up @@ -3,8 +3,8 @@
## Unreleased

- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.
- Updated `actix-tls` dependency to `4`.
- Updated `http` dependency to `1`.
- Updated `actix-tls` dependency to `3.2`.
- Added feature `http-1` for support to `http` crate version `1`.

## 3.1.0

Expand Down
8 changes: 6 additions & 2 deletions actix-http-test/Cargo.toml
Expand Up @@ -28,18 +28,22 @@ default = []
# openssl
openssl = ["tls-openssl", "awc/openssl"]

# use http crate v1
http-1 = ["dep:http-1", "awc/http-1"]

[dependencies]
actix-service = "2"
actix-codec = "0.5"
actix-tls = "4"
actix-tls = "3.1.1"
actix-utils = "3"
actix-rt = "2.2"
actix-server = "2"
awc = { version = "3", default-features = false }

bytes = "1"
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"
socket2 = "0.5"
serde = "1"
Expand Down
3 changes: 3 additions & 0 deletions actix-http-test/src/lib.rs
Expand Up @@ -10,6 +10,9 @@
#[cfg(feature = "openssl")]
extern crate tls_openssl as openssl;

#[cfg(feature = "http-1")]
extern crate http_1 as http;

use std::{net, thread, time::Duration};

use actix_codec::{AsyncRead, AsyncWrite, Framed};
Expand Down
3 changes: 2 additions & 1 deletion actix-http/CHANGES.md
Expand Up @@ -7,7 +7,8 @@
- Updated `zstd` dependency to `0.13`.
- Updated `http` dependency to `1`.
- 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

Expand Down
15 changes: 10 additions & 5 deletions actix-http/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "actix-http"
version = "3.4.0"
version = "3.5.0"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
Expand Down Expand Up @@ -33,6 +33,9 @@ default = []
# HTTP/2 protocol support
http2 = ["h2"]

# use http crate v1
http-1 = ["dep:http-1", "dep:h2-0_4"]

# WebSocket protocol implementation
ws = [
"local-channel",
Expand Down Expand Up @@ -75,7 +78,8 @@ bytestring = "1"
derive_more = "0.99.5"
encoding_rs = "0.8"
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"
httpdate = "1.0.1"
itoa = "1"
Expand All @@ -89,7 +93,8 @@ tokio-util = { version = "0.7", features = ["io", "codec"] }
tracing = { version = "0.1.30", default-features = false, features = ["log"] }

# http2
h2 = { version = "0.4", optional = true }
h2 = { version = "0.3", optional = true }
h2-0_4 = { package = "h2", version = "0.4", optional = true }

# websockets
local-channel = { version = "0.1", optional = true }
Expand All @@ -98,7 +103,7 @@ rand = { version = "0.8", optional = true }
sha1 = { version = "0.10", optional = true }

# openssl/rustls
actix-tls = { version = "4", default-features = false, optional = true }
actix-tls = { version = "3.1.1", default-features = false, optional = true }

# compress-*
brotli = { version = "3.3.3", optional = true }
Expand All @@ -108,7 +113,7 @@ zstd = { version = "0.13", optional = true }
[dev-dependencies]
actix-http-test = { version = "3", features = ["openssl"] }
actix-server = "2"
actix-tls = { version = "4", features = ["openssl"] }
actix-tls = { version = "3.1.1", features = ["openssl"] }
actix-web = "4"

async-stream = "0.3"
Expand Down
9 changes: 6 additions & 3 deletions actix-http/src/error.rs
Expand Up @@ -6,6 +6,9 @@ use derive_more::{Display, Error, From};
pub use http::Error as HttpError;
use http::{uri::InvalidUri, StatusCode};

#[cfg(feature = "http-1")]
use h2_0_4 as h2;

use crate::{body::BoxBody, Response};

pub struct Error {
Expand Down Expand Up @@ -274,7 +277,7 @@ pub enum PayloadError {
/// HTTP/2 payload error.
#[cfg(feature = "http2")]
#[display(fmt = "{}", _0)]
Http2Payload(::h2::Error),
Http2Payload(h2::Error),

/// Generic I/O error.
#[display(fmt = "{}", _0)]
Expand All @@ -297,8 +300,8 @@ impl std::error::Error for PayloadError {
}

#[cfg(feature = "http2")]
impl From<::h2::Error> for PayloadError {
fn from(err: ::h2::Error) -> Self {
impl From<h2::Error> for PayloadError {
fn from(err: h2::Error) -> Self {
PayloadError::Http2Payload(err)
}
}
Expand Down
3 changes: 3 additions & 0 deletions actix-http/src/h2/dispatcher.rs
Expand Up @@ -15,6 +15,9 @@ use actix_service::Service;
use actix_utils::future::poll_fn;
use bytes::{Bytes, BytesMut};
use futures_core::ready;
#[cfg(feature = "http-1")]
use h2_0_4 as h2;

use h2::{
server::{Connection, SendResponse},
Ping, PingPong,
Expand Down
2 changes: 2 additions & 0 deletions actix-http/src/h2/mod.rs
@@ -1,4 +1,6 @@
//! HTTP/2 protocol.
#[cfg(feature = "http-1")]
use h2_0_4 as h2;

use std::{
future::Future,
Expand Down
3 changes: 3 additions & 0 deletions actix-http/src/lib.rs
Expand Up @@ -28,6 +28,9 @@
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![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 mod body;
Expand Down
7 changes: 5 additions & 2 deletions actix-http/src/payload.rs
Expand Up @@ -10,6 +10,9 @@ use pin_project_lite::pin_project;

use crate::error::PayloadError;

#[cfg(feature = "http-1")]
use h2_0_4 as h2;

/// A boxed payload stream.
pub type BoxedPayloadStream = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>;

Expand Down Expand Up @@ -54,8 +57,8 @@ impl<S> From<crate::h2::Payload> for Payload<S> {
}

#[cfg(feature = "http2")]
impl<S> From<::h2::RecvStream> for Payload<S> {
fn from(stream: ::h2::RecvStream) -> Self {
impl<S> From<h2::RecvStream> for Payload<S> {
fn from(stream: h2::RecvStream) -> Self {
Payload::H2 {
payload: crate::h2::Payload::new(stream),
}
Expand Down
4 changes: 1 addition & 3 deletions actix-router/CHANGES.md
Expand Up @@ -3,9 +3,7 @@
## Unreleased

- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.

### Changed
- Updated `http` dependency to `1`.
- Added `http-1` feature for support to `http` v1.

## 0.5.1

Expand Down
10 changes: 7 additions & 3 deletions actix-router/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "actix-router"
version = "0.5.1"
version = "0.5.2"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>",
Expand All @@ -19,16 +19,20 @@ path = "src/lib.rs"
[features]
default = ["http"]

# use http v1
http-1 = ["dep:http-1"]

[dependencies]
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"
serde = "1"
tracing = { version = "0.1.30", default-features = false, features = ["log"] }

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
http = "1"
http = "0.2"
serde = { version = "1", features = ["derive"] }
percent-encoding = "2.1"

Expand Down
4 changes: 2 additions & 2 deletions actix-router/src/lib.rs
Expand Up @@ -15,10 +15,10 @@ mod resource;
mod resource_path;
mod router;

#[cfg(feature = "http")]
#[cfg(any(feature = "http", feature = "http-1"))]
mod url;

#[cfg(feature = "http")]
#[cfg(any(feature = "http", feature = "http-1"))]
pub use self::url::Url;
pub use self::{
de::PathDeserializer,
Expand Down
3 changes: 3 additions & 0 deletions actix-router/src/url.rs
@@ -1,5 +1,8 @@
use crate::{Quoter, ResourcePath};

#[cfg(feature = "http-1")]
use http_1 as http;

thread_local! {
static DEFAULT_QUOTER: Quoter = Quoter::new(b"", b"%/+");
}
Expand Down
3 changes: 2 additions & 1 deletion actix-web/CHANGES.md
Expand Up @@ -6,7 +6,8 @@

- Updated `zstd` dependency to `0.13`.
- 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

Expand Down
9 changes: 7 additions & 2 deletions actix-web/Cargo.toml
Expand Up @@ -49,6 +49,11 @@ secure-cookies = ["cookies", "cookie/secure"]

http2 = ["actix-http/http2"]

http-1 = [
"actix-http/http-1",
"actix-router/http-1"
]

# TLS via OpenSSL
openssl = ["http2", "actix-http/openssl", "actix-tls/accept", "actix-tls/openssl"]

Expand All @@ -73,10 +78,10 @@ actix-rt = { version = "2.6", default-features = false }
actix-server = "2"
actix-service = "2"
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-router = "0.5"
actix-router = "0.5.2"
actix-web-codegen = { version = "4.2", optional = true }

ahash = "0.8"
Expand Down
5 changes: 2 additions & 3 deletions awc/CHANGES.md
Expand Up @@ -4,9 +4,8 @@

- Update `trust-dns-resolver` dependency to `0.23`.
- Updated `zstd` dependency to `0.13`.
- Updated `http` dependency to `1`.
- 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`.

## 3.2.0

Expand Down
22 changes: 15 additions & 7 deletions awc/Cargo.toml
Expand Up @@ -21,7 +21,7 @@ path = "src/lib.rs"

[package.metadata.docs.rs]
# 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]
default = ["compress-brotli", "compress-gzip", "compress-zstd", "cookies"]
Expand Down Expand Up @@ -58,12 +58,18 @@ __compress = []
# DO NOT enable this over any internet use case.
dangerous-h2c = []

http-1 = [
"dep:http-1",
"actix-http/http-1",
"dep:h2-0_4",
]

[dependencies]
actix-codec = "0.5"
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-tls = { version = "4.0", features = ["connect", "uri"] }
actix-tls = { version = "3.1.1", features = ["connect", "uri"] }
actix-utils = "3"

base64 = "0.21"
Expand All @@ -72,8 +78,10 @@ cfg-if = "1"
derive_more = "0.99.5"
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
futures-util = { version = "0.3.17", default-features = false, features = ["alloc", "sink"] }
h2 = "0.4"
http = "1"
h2 = "0.3"
h2-0_4 = { version = "0.4", package = "h2", optional = true }
http = "0.2"
http-1 = { package = "http", version = "1", optional = true }
itoa = "1"
log =" 0.4"
mime = "0.3"
Expand All @@ -94,11 +102,11 @@ tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true, featu
trust-dns-resolver = { version = "0.23", optional = true }

[dev-dependencies]
actix-http = { version = "3.4", features = ["openssl"] }
actix-http = { version = "3.5", features = ["openssl"] }
actix-http-test = { version = "3", features = ["openssl"] }
actix-server = "2"
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-web = { version = "4", features = ["openssl"] }

Expand Down
3 changes: 3 additions & 0 deletions awc/src/builder.rs
Expand Up @@ -9,6 +9,9 @@ use actix_rt::net::{ActixStream, TcpStream};
use actix_service::{boxed, Service};
use base64::prelude::*;

#[cfg(feature = "http-1")]
use http_1 as http;

use crate::{
client::{
ClientConfig, ConnectInfo, Connector, ConnectorService, TcpConnectError, TcpConnection,
Expand Down
3 changes: 3 additions & 0 deletions awc/src/client/connection.rs
Expand Up @@ -11,6 +11,9 @@ use actix_http::{body::MessageBody, h1::ClientCodec, Payload, RequestHeadType, R
use actix_rt::task::JoinHandle;
use bytes::Bytes;
use futures_core::future::LocalBoxFuture;
#[cfg(feature = "http-1")]
use http_1 as http;

use h2::client::SendRequest;

use super::{error::SendRequestError, h1proto, h2proto, pool::Acquired};
Expand Down
3 changes: 3 additions & 0 deletions awc/src/client/connector.rs
Expand Up @@ -8,6 +8,9 @@ use std::{
time::Duration,
};

#[cfg(feature = "http-1")]
use http_1 as http;

use actix_http::Protocol;
use actix_rt::{
net::{ActixStream, TcpStream},
Expand Down

0 comments on commit 2b6cfb9

Please sign in to comment.