style: collapse nested if block

lint message: this `if` statement can be collapsed
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#collapsible_if
This commit is contained in:
Gwen Lg
2025-12-14 12:57:29 +01:00
parent 8772db8228
commit a426b00e87
3 changed files with 21 additions and 13 deletions
+13 -9
View File
@@ -269,20 +269,24 @@ fn verify_signed_headers(headers: &HeaderMap, signed_headers: &[HeaderName]) ->
return Err(Error::bad_request("Header `Host` should be signed"));
}
for (name, _) in headers.iter() {
// Enforce signature of all x-amz-* headers, except x-amz-content-sh256
// because it is included in the canonical request in all cases
if name.as_str().starts_with("x-amz-") && name != X_AMZ_CONTENT_SHA256 {
if !signed_headers.contains(name) {
return Err(Error::bad_request(format!(
"Header `{}` should be signed",
name
)));
}
// Enforce signature of some headers
if header_should_be_signed(name) && !signed_headers.contains(name) {
return Err(Error::bad_request(format!(
"Header `{}` should be signed",
name
)));
}
}
Ok(())
}
// Indicates whether a header is required to be signed
fn header_should_be_signed(name: &HeaderName) -> bool {
// Enforce signature of all x-amz-* headers, except x-amz-content-sh256
// because it is included in the canonical request in all cases
name.as_str().starts_with("x-amz-") && name != X_AMZ_CONTENT_SHA256
}
pub fn string_to_sign(datetime: &DateTime<Utc>, scope_string: &str, canonical_req: &str) -> String {
let mut hasher = Sha256::default();
hasher.update(canonical_req.as_bytes());