Skip to content

Commit

Permalink
feat(signer): enable HTTP compression using reqwest features
Browse files Browse the repository at this point in the history
  • Loading branch information
dlachaume committed Feb 6, 2025
1 parent 4992841 commit 4257c44
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mithril-signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ paste = "1.0.15"
prometheus = "0.13.4"
rand_chacha = "0.3.1"
rand_core = "0.6.4"
reqwest = { version = "0.12.12", features = ["json", "stream"] }
reqwest = { version = "0.12.12", features = [
"json",
"stream",
"gzip",
"zstd",
"deflate",
"brotli"
] }
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.138"
slog = { version = "2.7.0", features = [
Expand Down
31 changes: 31 additions & 0 deletions mithril-signer/src/services/aggregator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,4 +1093,35 @@ mod tests {
"Expected error message should not contain additional information \ngot '{root_cause:?}'"
);
}

#[tokio::test]
async fn test_sends_accept_encoding_header() {
let (server, client) = setup_server_and_client();
server.mock(|when, then| {
when.matches(|req| {
let headers = req.headers.clone().expect("HTTP headers not found");
let accept_encoding_header = headers
.iter()
.find(|(name, _values)| name.to_lowercase() == "accept-encoding")
.expect("Accept-Encoding header not found");

let header_value = accept_encoding_header.clone().1;
header_value.contains("gzip")
&& header_value.contains("br")
&& header_value.contains("deflate")
&& header_value.contains("zstd")
});

then.status(201);
});

client
.register_signatures(
&SignedEntityType::dummy(),
&fake_data::single_signatures((1..5).collect()),
&ProtocolMessage::default(),
)
.await
.expect("Should succeed with Accept-Encoding header");
}
}

0 comments on commit 4257c44

Please sign in to comment.