Skip to content

Commit 9c96dde

Browse files
committed
Update headers error propagation
1 parent 2bffc01 commit 9c96dde

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/client/auth/aws.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -268,23 +268,24 @@ pub async fn compute_aws_sigv4_payload(
268268
Error::authentication_error(MECH_NAME, &format!("Failed to build signing params: {e}"))
269269
})?
270270
.into();
271+
let headers: Result<Vec<_>> = request
272+
.headers()
273+
.iter()
274+
.map(|(k, v)| {
275+
let v = v.to_str().map_err(|_| {
276+
Error::authentication_error(
277+
MECH_NAME,
278+
"Failed to convert header value to valid UTF-8",
279+
)
280+
})?;
281+
Ok((k.as_str(), v))
282+
})
283+
.collect();
271284

272285
let signable_request = SignableRequest::new(
273286
request.method().as_str(),
274287
request.uri().to_string(),
275-
request
276-
.headers()
277-
.iter()
278-
.map(|(k, v)| {
279-
let value = std::str::from_utf8(v.as_bytes()).map_err(|_| {
280-
Error::authentication_error(
281-
MECH_NAME,
282-
"Failed to convert header value to valid UTF-8",
283-
)
284-
})?;
285-
Ok((k.as_str(), value))
286-
})
287-
.filter_map(Result::ok),
288+
headers?.into_iter(),
288289
SignableBody::Bytes(request.body().as_bytes()),
289290
)
290291
.map_err(|e| {

0 commit comments

Comments
 (0)