Compare commits

...

1 Commits

2 changed files with 22 additions and 14 deletions
+11 -2
View File
@@ -12,7 +12,13 @@ license.workspace = true
[dependencies] [dependencies]
async-trait = { workspace = true } async-trait = { workspace = true }
reqwest = { workspace = true, features = ["json", "gzip"] } reqwest = { workspace = true, features = [
"json",
"gzip",
"deflate",
"brotli",
"zstd",
] }
http.workspace = true http.workspace = true
url = { workspace = true } url = { workspace = true }
once_cell = { workspace = true } once_cell = { workspace = true }
@@ -30,7 +36,10 @@ mime = { workspace = true }
nym-bin-common = { path = "../bin-common" } nym-bin-common = { path = "../bin-common" }
[target."cfg(not(target_arch = \"wasm32\"))".dependencies] [target."cfg(not(target_arch = \"wasm32\"))".dependencies]
hickory-resolver = { workspace = true, features = ["dns-over-https-rustls", "webpki-roots"] } hickory-resolver = { workspace = true, features = [
"dns-over-https-rustls",
"webpki-roots",
] }
# for request timeout until https://github.com/seanmonstar/reqwest/issues/1135 is fixed # for request timeout until https://github.com/seanmonstar/reqwest/issues/1135 is fixed
[target."cfg(target_arch = \"wasm32\")".dependencies.wasmtimer] [target."cfg(target_arch = \"wasm32\")".dependencies.wasmtimer]
+11 -12
View File
@@ -265,14 +265,18 @@ impl ClientBuilder {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
let reqwest_client_builder = { let reqwest_client_builder = {
let r = reqwest::ClientBuilder::new(); // Note: I believe the manual enable calls for the compression methods are extra
// as the various compression features for `reqwest` crate should be enabled
// Note this is extra as the `gzip` feature for `reqwest` crate should be enabled which // just by including the feature which:
// `"Enable[s] auto gzip decompression by checking the Content-Encoding response header."` // `"Enable[s] auto decompression by checking the Content-Encoding response header."`
// //
// I am going to leave it here anyways so that gzip decompression is attempted even if // I am going to leave these here anyways so that removing a decompression method
// that feature is removed. // from the features list will throw an error if it is not also removed here.
r.gzip(true) reqwest::ClientBuilder::new()
.gzip(true)
.deflate(true)
.brotli(true)
.zstd(true)
}; };
ClientBuilder { ClientBuilder {
@@ -535,11 +539,6 @@ impl ApiClientCore for Client {
let mut request = self.reqwest_client.request(method.clone(), url); let mut request = self.reqwest_client.request(method.clone(), url);
// Indicate that compressed responses are preferred, but if not supported other encodings are fine.
// TODO: Down the road we can be more selective about adding this, but it's inclusion here guarantees
// that we use compression when available.
request = request.header(reqwest::header::ACCEPT_ENCODING, "gzip;q=1.0, *;q=0.5");
if let Some(body) = json_body { if let Some(body) = json_body {
request = request.json(body); request = request.json(body);
} }