Skip to content

Commit 76999fa

Browse files
Merge branch 'master' into expose-urls-tower-http
2 parents 5586145 + 4cb2866 commit 76999fa

File tree

16 files changed

+179
-69
lines changed

16 files changed

+179
-69
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ jobs:
318318
cargo update -p hashbrown --precise 0.15.0
319319
cargo update -p native-tls --precise 0.2.13
320320
cargo update -p once_cell --precise 1.20.3
321+
cargo update -p tracing-core --precise 0.1.33
321322
322323
- uses: Swatinem/rust-cache@v2
323324

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v0.12.20
2+
3+
- Add `ClientBuilder::tcp_user_timeout(Duration)` option to set `TCP_USER_TIMEOUT`.
4+
- Fix proxy headers only using the first matched proxy.
5+
- (wasm) Fix re-adding `Error::is_status()`.
6+
17
## v0.12.19
28

39
- Fix redirect that changes the method to GET should remove payload headers.

Cargo.toml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "reqwest"
3-
version = "0.12.19"
3+
version = "0.12.20"
44
description = "higher level HTTP client library"
55
keywords = ["http", "request", "client"]
66
categories = ["web-programming::http-client", "wasm"]
@@ -53,7 +53,7 @@ rustls-tls-native-roots = ["rustls-tls-native-roots-no-provider", "__rustls-ring
5353

5454
blocking = ["dep:futures-channel", "futures-channel?/sink", "dep:futures-util", "futures-util?/io", "futures-util?/sink", "tokio/sync"]
5555

56-
charset = ["dep:encoding_rs"]
56+
charset = ["dep:encoding_rs", "dep:mime"]
5757

5858
cookies = ["dep:cookie_crate", "dep:cookie_store"]
5959

@@ -71,11 +71,11 @@ multipart = ["dep:mime_guess", "dep:futures-util"]
7171

7272
# Deprecated, remove this feature while bumping minor versions.
7373
trust-dns = []
74-
hickory-dns = ["dep:hickory-resolver"]
74+
hickory-dns = ["dep:hickory-resolver", "dep:once_cell"]
7575

7676
stream = ["tokio/fs", "dep:futures-util", "dep:tokio-util", "dep:wasm-streams"]
7777

78-
socks = ["dep:tokio-socks"]
78+
socks = []
7979

8080
# Use the system's proxy configuration.
8181
system-proxy = ["hyper-util/client-proxy-system"]
@@ -84,7 +84,7 @@ system-proxy = ["hyper-util/client-proxy-system"]
8484
macos-system-configuration = ["system-proxy"]
8585

8686
# Experimental HTTP/3 client.
87-
http3 = ["rustls-tls-manual-roots", "dep:h3", "dep:h3-quinn", "dep:quinn", "dep:slab", "dep:futures-channel", "tokio/macros"]
87+
http3 = ["rustls-tls-manual-roots", "dep:h3", "dep:h3-quinn", "dep:quinn", "tokio/macros"]
8888

8989

9090
# Internal (PRIVATE!) features used to aid testing.
@@ -124,18 +124,16 @@ http-body-util = "0.1"
124124
hyper = { version = "1.1", features = ["http1", "client"] }
125125
hyper-util = { version = "0.1.12", features = ["http1", "client", "client-legacy", "client-proxy", "tokio"] }
126126
h2 = { version = "0.4", optional = true }
127-
once_cell = "1.18"
128127
log = "0.4.17"
129-
mime = "0.3.16"
130128
percent-encoding = "2.3"
131129
tokio = { version = "1.0", default-features = false, features = ["net", "time"] }
132130
tower = { version = "0.5.2", default-features = false, features = ["timeout", "util"] }
133131
tower-http = { version = "0.6.5", default-features = false, features = ["follow-redirect"] }
134132
pin-project-lite = "0.2.11"
135-
ipnet = "2.3"
136133

137134
# Optional deps...
138135
rustls-pki-types = { version = "1.9.0", features = ["std"], optional = true }
136+
mime = { version = "0.3.16", optional = true }
139137

140138
## default-tls
141139
hyper-tls = { version = "0.6", optional = true }
@@ -157,17 +155,14 @@ cookie_store = { version = "0.21.0", optional = true }
157155
async-compression = { version = "0.4.0", default-features = false, features = ["tokio"], optional = true }
158156
tokio-util = { version = "0.7.9", default-features = false, features = ["codec", "io"], optional = true }
159157

160-
## socks
161-
tokio-socks = { version = "0.5.2", optional = true }
162-
163158
## hickory-dns
164159
hickory-resolver = { version = "0.24", optional = true, features = ["tokio-runtime"] }
160+
once_cell = { version = "1.18", optional = true }
165161

166162
# HTTP/3 experimental support
167163
h3 = { version = "0.0.8", optional = true }
168164
h3-quinn = { version = "0.0.10", optional = true }
169165
quinn = { version = "0.11.1", default-features = false, features = ["rustls", "runtime-tokio"], optional = true }
170-
slab = { version = "0.4.9", optional = true } # just to get minimal versions working with quinn
171166
futures-channel = { version = "0.3", optional = true }
172167

173168
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]

src/async_impl/body.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::time::Duration;
77
use bytes::Bytes;
88
use http_body::Body as HttpBody;
99
use http_body_util::combinators::BoxBody;
10-
//use sync_wrapper::SyncWrapper;
1110
use pin_project_lite::pin_project;
1211
#[cfg(feature = "stream")]
1312
use tokio::fs::File;

src/async_impl/client.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ struct Config {
167167
tcp_keepalive: Option<Duration>,
168168
tcp_keepalive_interval: Option<Duration>,
169169
tcp_keepalive_retries: Option<u32>,
170+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
171+
tcp_user_timeout: Option<Duration>,
170172
#[cfg(any(feature = "native-tls", feature = "__rustls"))]
171173
identity: Option<Identity>,
172174
proxies: Vec<ProxyMatcher>,
@@ -290,6 +292,8 @@ impl ClientBuilder {
290292
tcp_keepalive: None, //Some(Duration::from_secs(60)),
291293
tcp_keepalive_interval: None,
292294
tcp_keepalive_retries: None,
295+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
296+
tcp_user_timeout: None,
293297
proxies: Vec::new(),
294298
auto_sys_proxy: true,
295299
redirect_policy: redirect::Policy::default(),
@@ -899,6 +903,8 @@ impl ClientBuilder {
899903
connector_builder.set_keepalive(config.tcp_keepalive);
900904
connector_builder.set_keepalive_interval(config.tcp_keepalive_interval);
901905
connector_builder.set_keepalive_retries(config.tcp_keepalive_retries);
906+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
907+
connector_builder.set_tcp_user_timeout(config.tcp_user_timeout);
902908

903909
#[cfg(feature = "socks")]
904910
connector_builder.set_socks_resolver(resolver);
@@ -1691,6 +1697,21 @@ impl ClientBuilder {
16911697
self
16921698
}
16931699

1700+
/// Set that all sockets have `TCP_USER_TIMEOUT` set with the supplied duration.
1701+
///
1702+
/// This option controls how long transmitted data may remain unacknowledged before
1703+
/// the connection is force-closed.
1704+
///
1705+
/// The current default is `None` (option disabled).
1706+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
1707+
pub fn tcp_user_timeout<D>(mut self, val: D) -> ClientBuilder
1708+
where
1709+
D: Into<Option<Duration>>,
1710+
{
1711+
self.config.tcp_user_timeout = val.into();
1712+
self
1713+
}
1714+
16941715
// TLS options
16951716

16961717
/// Add a custom root certificate.
@@ -2501,7 +2522,7 @@ impl Client {
25012522
.map(Box::pin);
25022523

25032524
Pending {
2504-
inner: PendingInner::Request(PendingRequest {
2525+
inner: PendingInner::Request(Box::pin(PendingRequest {
25052526
method,
25062527
url,
25072528
headers,
@@ -2515,7 +2536,7 @@ impl Client {
25152536
total_timeout,
25162537
read_timeout_fut,
25172538
read_timeout: self.inner.read_timeout,
2518-
}),
2539+
})),
25192540
}
25202541
}
25212542

@@ -2798,7 +2819,7 @@ pin_project! {
27982819
}
27992820

28002821
enum PendingInner {
2801-
Request(PendingRequest),
2822+
Request(Pin<Box<PendingRequest>>),
28022823
Error(Option<crate::Error>),
28032824
}
28042825

@@ -3005,7 +3026,7 @@ impl Future for PendingRequest {
30053026
}
30063027
}
30073028

3008-
return Poll::Ready(Err(e));
3029+
return Poll::Ready(Err(e.if_no_url(|| self.url.clone())));
30093030
}
30103031
Poll::Ready(Ok(res)) => res.map(super::body::boxed),
30113032
Poll::Pending => return Poll::Pending,
@@ -3098,4 +3119,10 @@ mod tests {
30983119
assert!(err.is_builder());
30993120
assert_eq!(url_str, err.url().unwrap().as_str());
31003121
}
3122+
3123+
#[test]
3124+
fn test_future_size() {
3125+
let s = std::mem::size_of::<super::Pending>();
3126+
assert!(s < 128, "size_of::<Pending>() == {s}, too big");
3127+
}
31013128
}

src/async_impl/multipart.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ impl<P: PartProps> FormParts<P> {
402402
}
403403

404404
// If predictable, computes the length the request will have
405-
// The length should be preditable if only String and file fields have been added,
405+
// The length should be predictable if only String and file fields have been added,
406406
// but not if a generic reader has been added;
407407
pub(crate) fn compute_length(&mut self) -> Option<u64> {
408408
let mut length = 0u64;

src/blocking/client.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,20 @@ impl ClientBuilder {
610610
self.with_inner(move |inner| inner.tcp_keepalive_retries(retries))
611611
}
612612

613+
/// Set that all sockets have `TCP_USER_TIMEOUT` set with the supplied duration.
614+
///
615+
/// This option controls how long transmitted data may remain unacknowledged before
616+
/// the connection is force-closed.
617+
///
618+
/// The current default is `None` (option disabled).
619+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
620+
pub fn tcp_user_timeout<D>(self, val: D) -> ClientBuilder
621+
where
622+
D: Into<Option<Duration>>,
623+
{
624+
self.with_inner(move |inner| inner.tcp_user_timeout(val))
625+
}
626+
613627
// TLS options
614628

615629
/// Add a custom root certificate.

0 commit comments

Comments
 (0)