Skip to content

Commit 70934cc

Browse files
committed
fix(async-stripe): Fix header name, extract it to const
http crate does not allow uppercase characters in header name and it was causing crashes when hitting thing branch with error "index out of bounds." The error should happen at compile time, but for some reason the HeaderName::from_static was executed at runtime, so this commit forces it to be executed at compile time by extracing it into the const. Signed-off-by: Robin Ilyk <[email protected]>
1 parent 3691044 commit 70934cc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: async-stripe/src/hyper/client.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ impl Client {
109109
let mut last_error = StripeError::ClientError("invalid strategy".into());
110110

111111
if let Some(key) = strategy.get_key() {
112-
req_builder = req_builder.header(HeaderName::from_static("Idempotency-Key"), key);
112+
const HEADER_NAME: HeaderName = HeaderName::from_static("idempotency-key");
113+
assert!(!key.is_empty(), "idempotency key is empty");
114+
req_builder = req_builder.header(HEADER_NAME, key);
113115
}
114116

115117
loop {

0 commit comments

Comments
 (0)