Skip to content

Commit b337273

Browse files
committed
Check in bytes constructor
Signed-off-by: Ryan Levick <[email protected]>
1 parent 2d77028 commit b337273

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sdk/rust/src/http.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ impl HeaderValue {
289289
/// Construct a `HeaderValue` from a bag of bytes
290290
pub fn bytes(bytes: Vec<u8>) -> HeaderValue {
291291
HeaderValue {
292-
inner: HeaderValueRep::Bytes(bytes),
292+
inner: String::from_utf8(bytes)
293+
.map(HeaderValueRep::String)
294+
.unwrap_or_else(|e| HeaderValueRep::Bytes(e.into_bytes())),
293295
}
294296
}
295297

0 commit comments

Comments
 (0)