Skip to content

Commit dcbdcd2

Browse files
authored
feat(volo-http): support http2 and connection pool for client (#574)
This commit adds HTTP/2 support for the HTTP client and connection pool support for both HTTP/1 and HTTP/2. As the client interface is relatively simple, this commit introduces a small number of breaking changes: Since this PR supports HTTP/2, some configurations that only apply to HTTP/1 are marked as `deprecated` or removed. Users should configure via `builder.http1_config()`. TODO: 1. `rustls` supports setting ALPN for each TLS connection, but `tokio-rustls` does not expose this feature, it can only set ALPN for the entire configuration (in other words, `tokio_rustls::TlsConnector`). We can use `rustls` directly or submit an issue to `tokio-rustls` for discussion to fix it. 2. `httpbin` supports HTTP/1 based on pure TCP or TLS, and HTTP/2 based on TLS, but does not support HTTP/2 based on Cleartext (h2c), so there is currently no test case that only supports HTTP/2 without TLS (although it is a unnecessary feature). We should find a site that supports h2c for subsequent testing. --------- Signed-off-by: Yu Li <[email protected]>
1 parent e82d140 commit dcbdcd2

32 files changed

+2853
-809
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/clippy-and-test.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ echo_command cargo clippy -p volo-grpc --no-default-features --features native-t
3030
echo_command cargo clippy -p volo-grpc --no-default-features --features native-tls-vendored -- --deny warnings
3131
echo_command cargo clippy -p volo-grpc --no-default-features --features grpc-web -- --deny warnings
3232
echo_command cargo clippy -p volo-http --no-default-features -- --deny warnings
33-
echo_command cargo clippy -p volo-http --no-default-features --features default-client -- --deny warnings
34-
echo_command cargo clippy -p volo-http --no-default-features --features default-server -- --deny warnings
35-
echo_command cargo clippy -p volo-http --no-default-features --features client,server,http1 -- --deny warnings
36-
echo_command cargo clippy -p volo-http --no-default-features --features client,server,http2 -- --deny warnings
33+
echo_command cargo clippy -p volo-http --no-default-features --features client,http1,json -- --deny warnings
34+
echo_command cargo clippy -p volo-http --no-default-features --features client,http2,json -- --deny warnings
35+
echo_command cargo clippy -p volo-http --no-default-features --features server,http1,query,form,json,multipart,ws -- --deny warnings
36+
echo_command cargo clippy -p volo-http --no-default-features --features server,http2,query,form,json,multipart,ws -- --deny warnings
3737
echo_command cargo clippy -p volo-http --no-default-features --features full -- --deny warnings
3838
echo_command cargo clippy -p volo -- --deny warnings
3939
echo_command cargo clippy -p volo --no-default-features --features rustls-aws-lc-rs -- --deny warnings
@@ -47,7 +47,8 @@ echo_command cargo clippy -p examples --features tls -- --deny warnings
4747
# Test
4848
echo_command cargo test -p volo-thrift
4949
echo_command cargo test -p volo-grpc --features rustls
50-
echo_command cargo test -p volo-http --features default-client,default-server
50+
echo_command cargo test -p volo-http --features client,server,http1,query,form,json,tls,cookie,multipart,ws
51+
echo_command cargo test -p volo-http --features client,server,http2,query,form,json,tls,cookie,multipart,ws
5152
echo_command cargo test -p volo-http --features full
5253
echo_command cargo test -p volo --features rustls
5354
echo_command cargo test -p volo-build

volo-http/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "volo-http"
3-
version = "0.4.0-rc.1"
3+
version = "0.4.0-rc.2"
44
edition.workspace = true
55
homepage.workspace = true
66
repository.workspace = true
@@ -96,7 +96,7 @@ tokio-test.workspace = true
9696
[features]
9797
default = []
9898

99-
default-client = ["client", "json"]
99+
default-client = ["client", "http1", "http2", "json"]
100100
default-server = ["server", "http1", "http2", "query", "form", "json", "multipart"]
101101

102102
full = [
@@ -112,7 +112,6 @@ http2 = ["hyper/http2", "hyper-util/http2"]
112112

113113
client = [
114114
"hyper/client",
115-
"http1", # to be removed
116115
"dep:async-broadcast", "dep:chrono", "dep:hickory-resolver",
117116
] # client core
118117
server = [

0 commit comments

Comments
 (0)