Skip to content

Commit 856dd01

Browse files
authored
Upgrade http, ruma, reqwest and wiremock dependencies (#3362)
They need to be updated together because the latters depend on the former. matrix-authentication-service is still using http 0.2 so we need to add a conversion layer between both major versions for OIDC requests. We need to update vodozemac too because of a dependency resolution issue. Signed-off-by: Kévin Commaille <[email protected]>
1 parent ea1a010 commit 856dd01

File tree

13 files changed

+521
-406
lines changed

13 files changed

+521
-406
lines changed

Cargo.lock

+303-372
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ futures-executor = "0.3.21"
3636
futures-util = { version = "0.3.26", default-features = false, features = [
3737
"alloc",
3838
] }
39-
http = "0.2.6"
39+
http = "1.1.0"
4040
imbl = "2.0.0"
4141
itertools = "0.12.0"
42-
ruma = { git = "https://github.com/ruma/ruma", rev = "21b644ac6ae1c7d4a4f7e98a6481a3318f2deeaa", features = [
42+
ruma = { git = "https://github.com/ruma/ruma", rev = "b6200c01a120120faf9f744ab4f171ff3beefd72", features = [
4343
"client-api-c",
4444
"compat-upload-signatures",
4545
"compat-user-id",
@@ -48,7 +48,7 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "21b644ac6ae1c7d4a4f7e98a64
4848
"unstable-msc3401",
4949
"unstable-msc3266",
5050
] }
51-
ruma-common = { git = "https://github.com/ruma/ruma", rev = "21b644ac6ae1c7d4a4f7e98a6481a3318f2deeaa" }
51+
ruma-common = { git = "https://github.com/ruma/ruma", rev = "b6200c01a120120faf9f744ab4f171ff3beefd72" }
5252
once_cell = "1.16.0"
5353
rand = "0.8.5"
5454
serde = "1.0.151"
@@ -63,8 +63,8 @@ tracing = { version = "0.1.40", default-features = false, features = ["std"] }
6363
tracing-core = "0.1.32"
6464
uniffi = { git = "https://github.com/mozilla/uniffi-rs", rev = "789a9023b522562a95618443cee5a0d4f111c4c7" }
6565
uniffi_bindgen = { git = "https://github.com/mozilla/uniffi-rs", rev = "789a9023b522562a95618443cee5a0d4f111c4c7" }
66-
vodozemac = { git="https://github.com/matrix-org/vodozemac", rev = "0c75746fc8a5eda4a0e490d345d1798b4c6cbd67" }
67-
wiremock = "0.5.21"
66+
vodozemac = { git="https://github.com/matrix-org/vodozemac", rev = "2722fb9518059ccd2ad55470f4c4d3ba5e447bd9" }
67+
wiremock = "0.6.0"
6868
zeroize = "1.6.0"
6969

7070
matrix-sdk = { path = "crates/matrix-sdk", version = "0.7.0", default-features = false }

bindings/matrix-sdk-ffi/src/platform.rs

-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ pub fn create_otlp_tracer(
6666

6767
let auth = STANDARD.encode(format!("{user}:{password}"));
6868
let headers = HashMap::from([("Authorization".to_owned(), format!("Basic {auth}"))]);
69-
let http_client = matrix_sdk::reqwest::ClientBuilder::new().build()?;
7069

7170
let exporter = opentelemetry_otlp::new_exporter()
7271
.http()
73-
.with_http_client(http_client)
7472
.with_protocol(Protocol::HttpBinary)
7573
.with_endpoint(otlp_endpoint)
7674
.with_headers(headers);

crates/matrix-sdk-ui/src/room_list_service/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ mod tests {
661661
impl Match for SlidingSyncMatcher {
662662
fn matches(&self, request: &Request) -> bool {
663663
request.url.path() == "/_matrix/client/unstable/org.matrix.msc3575/sync"
664-
&& request.method == Method::Post
664+
&& request.method == Method::POST
665665
}
666666
}
667667

crates/matrix-sdk-ui/tests/integration/sliding_sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(crate) struct PartialSlidingSyncRequest {
4848
impl Match for SlidingSyncMatcher {
4949
fn matches(&self, request: &Request) -> bool {
5050
request.url.path() == "/_matrix/client/unstable/org.matrix.msc3575/sync"
51-
&& request.method == Method::Post
51+
&& request.method == Method::POST
5252
}
5353
}
5454

crates/matrix-sdk-ui/tests/integration/timeline/sliding_sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ struct SlidingSyncMatcher;
299299
impl Match for SlidingSyncMatcher {
300300
fn matches(&self, request: &Request) -> bool {
301301
request.url.path() == "/_matrix/client/unstable/org.matrix.msc3575/sync"
302-
&& request.method == Method::Post
302+
&& request.method == Method::POST
303303
}
304304
}
305305

crates/matrix-sdk/Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ uniffi = ["dep:uniffi", "matrix-sdk-base/uniffi"]
4646
experimental-oidc = [
4747
"ruma/unstable-msc2967",
4848
"dep:chrono",
49+
"dep:http_old",
4950
"dep:language-tags",
5051
"dep:mas-oidc-client",
5152
"dep:rand",
@@ -83,6 +84,7 @@ eyre = { version = "0.6.8", optional = true }
8384
futures-core = { workspace = true }
8485
futures-util = { workspace = true }
8586
http = { workspace = true }
87+
http_old = { package = "http", version = "0.2", optional = true }
8688
imbl = { workspace = true, features = ["serde"] }
8789
indexmap = "2.0.2"
8890
js_int = "0.2.2"
@@ -120,14 +122,14 @@ optional = true
120122

121123
[target.'cfg(target_arch = "wasm32")'.dependencies]
122124
gloo-timers = { version = "0.3.0", features = ["futures"] }
123-
reqwest = { version = "0.11.10", default_features = false }
125+
reqwest = { version = "0.12.4", default_features = false }
124126
tokio = { workspace = true, features = ["macros"] }
125127

126128
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
127129
backoff = { version = "0.4.0", features = ["tokio"] }
128130
# only activate reqwest's stream feature on non-wasm, the wasm part seems to not
129131
# support *sending* streams, which makes it useless for us.
130-
reqwest = { version = "0.11.10", default_features = false, features = ["stream"] }
132+
reqwest = { version = "0.12.4", default_features = false, features = ["stream"] }
131133
tokio = { workspace = true, features = ["fs", "rt", "macros"] }
132134
tokio-util = "0.7.9"
133135
wiremock = { workspace = true, optional = true }
@@ -151,7 +153,7 @@ wasm-bindgen-test = "0.3.33"
151153

152154
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
153155
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
154-
wiremock = { version = "0.5.13" }
156+
wiremock = { workspace = true }
155157

156158
[[test]]
157159
name = "integration"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
//! Helper traits to convert between http 0.2 and http 1.x.
2+
3+
/// Convert from http 1.x to http 0.2
4+
pub trait ToHttpOld {
5+
type Output;
6+
7+
fn to_http_old(self) -> Self::Output;
8+
}
9+
10+
impl<T> ToHttpOld for http::Response<T> {
11+
type Output = http_old::Response<T>;
12+
13+
fn to_http_old(self) -> Self::Output {
14+
let (parts, body) = self.into_parts();
15+
let mut response = http_old::Response::new(body);
16+
17+
*response.status_mut() = parts.status.to_http_old();
18+
*response.version_mut() = parts.version.to_http_old();
19+
*response.headers_mut() = parts.headers.to_http_old();
20+
// We cannot do anything about extensions because we cannot iterate over them.
21+
22+
response
23+
}
24+
}
25+
26+
impl ToHttpOld for http::StatusCode {
27+
type Output = http_old::StatusCode;
28+
29+
fn to_http_old(self) -> Self::Output {
30+
http_old::StatusCode::from_u16(self.as_u16())
31+
.expect("status code should be valid between both versions")
32+
}
33+
}
34+
35+
impl ToHttpOld for http::Version {
36+
type Output = http_old::Version;
37+
38+
fn to_http_old(self) -> Self::Output {
39+
if self == http::Version::HTTP_09 {
40+
http_old::Version::HTTP_09
41+
} else if self == http::Version::HTTP_10 {
42+
http_old::Version::HTTP_10
43+
} else if self == http::Version::HTTP_11 {
44+
http_old::Version::HTTP_11
45+
} else if self == http::Version::HTTP_2 {
46+
http_old::Version::HTTP_2
47+
} else if self == http::Version::HTTP_3 {
48+
http_old::Version::HTTP_3
49+
} else {
50+
// Current http code doesn't have other variants.
51+
unreachable!()
52+
}
53+
}
54+
}
55+
56+
impl ToHttpOld for http::HeaderMap<http::HeaderValue> {
57+
type Output = http_old::HeaderMap<http_old::HeaderValue>;
58+
59+
fn to_http_old(self) -> Self::Output {
60+
let mut map = http_old::HeaderMap::new();
61+
map.extend(
62+
self.into_iter()
63+
.map(|(name, value)| (name.map(ToHttpOld::to_http_old), value.to_http_old())),
64+
);
65+
66+
map
67+
}
68+
}
69+
70+
impl ToHttpOld for http::HeaderName {
71+
type Output = http_old::HeaderName;
72+
73+
fn to_http_old(self) -> Self::Output {
74+
http_old::HeaderName::from_bytes(self.as_ref())
75+
.expect("header name should be valid between both versions")
76+
}
77+
}
78+
79+
impl ToHttpOld for http::HeaderValue {
80+
type Output = http_old::HeaderValue;
81+
82+
fn to_http_old(self) -> Self::Output {
83+
http_old::HeaderValue::from_bytes(self.as_bytes())
84+
.expect("header value should be valid between both versions")
85+
}
86+
}
87+
88+
/// Convert from http 0.2 to http 1.x
89+
pub trait ToHttpNew {
90+
type Output;
91+
92+
fn to_http_new(self) -> Self::Output;
93+
}
94+
95+
impl<T> ToHttpNew for http_old::Request<T> {
96+
type Output = http::Request<T>;
97+
98+
fn to_http_new(self) -> Self::Output {
99+
let (parts, body) = self.into_parts();
100+
let mut request = http::Request::new(body);
101+
102+
*request.method_mut() = parts.method.to_http_new();
103+
*request.uri_mut() = parts.uri.to_http_new();
104+
*request.version_mut() = parts.version.to_http_new();
105+
*request.headers_mut() = parts.headers.to_http_new();
106+
// We cannot do anything about extensions because we cannot iterate over them.
107+
108+
request
109+
}
110+
}
111+
112+
impl ToHttpNew for http_old::Method {
113+
type Output = http::Method;
114+
115+
fn to_http_new(self) -> Self::Output {
116+
self.as_str().parse().expect("method should be valid between both versions")
117+
}
118+
}
119+
120+
impl ToHttpNew for http_old::Uri {
121+
type Output = http::Uri;
122+
123+
fn to_http_new(self) -> Self::Output {
124+
self.to_string().parse().expect("URI should be valid between both versions")
125+
}
126+
}
127+
128+
impl ToHttpNew for http_old::Version {
129+
type Output = http::Version;
130+
131+
fn to_http_new(self) -> Self::Output {
132+
if self == http_old::Version::HTTP_09 {
133+
http::Version::HTTP_09
134+
} else if self == http_old::Version::HTTP_10 {
135+
http::Version::HTTP_10
136+
} else if self == http_old::Version::HTTP_11 {
137+
http::Version::HTTP_11
138+
} else if self == http_old::Version::HTTP_2 {
139+
http::Version::HTTP_2
140+
} else if self == http_old::Version::HTTP_3 {
141+
http::Version::HTTP_3
142+
} else {
143+
// Current http code doesn't have other variants.
144+
unreachable!()
145+
}
146+
}
147+
}
148+
149+
impl ToHttpNew for http_old::HeaderMap<http_old::HeaderValue> {
150+
type Output = http::HeaderMap<http::HeaderValue>;
151+
152+
fn to_http_new(self) -> Self::Output {
153+
let mut map = http::HeaderMap::new();
154+
map.extend(
155+
self.into_iter()
156+
.map(|(name, value)| (name.map(ToHttpNew::to_http_new), value.to_http_new())),
157+
);
158+
159+
map
160+
}
161+
}
162+
163+
impl ToHttpNew for http_old::HeaderName {
164+
type Output = http::HeaderName;
165+
166+
fn to_http_new(self) -> Self::Output {
167+
http::HeaderName::from_bytes(self.as_ref())
168+
.expect("header name should be valid between both versions")
169+
}
170+
}
171+
172+
impl ToHttpNew for http_old::HeaderValue {
173+
type Output = http::HeaderValue;
174+
175+
fn to_http_new(self) -> Self::Output {
176+
http::HeaderValue::from_bytes(self.as_bytes())
177+
.expect("header value should be valid between both versions")
178+
}
179+
}

crates/matrix-sdk/src/http_client/mod.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ use tracing::{debug, field::debug, instrument, trace};
3434

3535
use crate::{config::RequestConfig, error::HttpError};
3636

37+
#[cfg(feature = "experimental-oidc")]
38+
mod http_helpers;
3739
#[cfg(not(target_arch = "wasm32"))]
3840
mod native;
3941
#[cfg(target_arch = "wasm32")]
4042
mod wasm;
4143

44+
#[cfg(feature = "experimental-oidc")]
45+
use http_helpers::{ToHttpNew, ToHttpOld};
4246
#[cfg(not(target_arch = "wasm32"))]
4347
pub(crate) use native::HttpSettings;
4448

@@ -225,8 +229,8 @@ async fn response_to_http_response(
225229
}
226230

227231
#[cfg(feature = "experimental-oidc")]
228-
impl tower::Service<http::Request<Bytes>> for HttpClient {
229-
type Response = http::Response<Bytes>;
232+
impl tower::Service<http_old::Request<Bytes>> for HttpClient {
233+
type Response = http_old::Response<Bytes>;
230234
type Error = tower::BoxError;
231235
type Future = futures_core::future::BoxFuture<'static, Result<Self::Response, Self::Error>>;
232236

@@ -237,13 +241,19 @@ impl tower::Service<http::Request<Bytes>> for HttpClient {
237241
std::task::Poll::Ready(Ok(()))
238242
}
239243

240-
fn call(&mut self, req: http::Request<Bytes>) -> Self::Future {
244+
fn call(&mut self, req: http_old::Request<Bytes>) -> Self::Future {
241245
let inner = self.inner.clone();
242246

243247
let fut = async move {
244-
native::send_request(&inner, &req, DEFAULT_REQUEST_TIMEOUT, Default::default())
245-
.await
246-
.map_err(Into::into)
248+
native::send_request(
249+
&inner,
250+
&req.to_http_new(),
251+
DEFAULT_REQUEST_TIMEOUT,
252+
Default::default(),
253+
)
254+
.await
255+
.map(ToHttpOld::to_http_old)
256+
.map_err(Into::into)
247257
};
248258
Box::pin(fut)
249259
}

crates/matrix-sdk/src/oidc/backend/mock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
use std::sync::{Arc, Mutex};
1818

19-
use http::StatusCode;
19+
use http_old::StatusCode;
2020
use mas_oidc_client::{
2121
error::{
2222
DiscoveryError,

crates/matrix-sdk/src/sliding_sync/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ mod tests {
10931093
impl Match for SlidingSyncMatcher {
10941094
fn matches(&self, request: &Request) -> bool {
10951095
request.url.path() == "/_matrix/client/unstable/org.matrix.msc3575/sync"
1096-
&& request.method == Method::Post
1096+
&& request.method == Method::POST
10971097
}
10981098
}
10991099

@@ -1167,7 +1167,7 @@ mod tests {
11671167
fn matches(&self, request: &Request) -> bool {
11681168
request.url.path()
11691169
== format!("/_matrix/client/r0/rooms/{room_id}/members", room_id = self.0)
1170-
&& request.method == Method::Get
1170+
&& request.method == Method::GET
11711171
}
11721172
}
11731173

testing/matrix-sdk-integration-testing/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ eyeball-im = { workspace = true }
1515
futures = { version = "0.3.29", features = ["executor"] }
1616
futures-core = { workspace = true }
1717
futures-util = { workspace = true }
18-
http = "0.2.11"
18+
http = { workspace = true }
1919
matrix-sdk = { workspace = true, default-features = true, features = ["testing", "qrcode"] }
2020
matrix-sdk-ui = { workspace = true, default-features = true }
2121
matrix-sdk-test = { workspace = true }
2222
once_cell = { workspace = true }
2323
rand = { workspace = true }
2424
stream_assert = "0.1.1"
25-
reqwest = "0.11.20"
25+
reqwest = "0.12.4"
2626
serde_json = "1.0.108"
2727
tempfile = "3.3.0"
2828
tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros"] }

0 commit comments

Comments
 (0)