Skip to content

Commit

Permalink
remove unwraps of HeaderName and HeaderValue (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuqdog authored Dec 19, 2024
1 parent c995c0a commit 22559a8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/rpc/webrtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,16 @@ pub(crate) fn trailers_from_proto(proto: ResponseTrailers) -> HeaderMap {
None => "0".to_string(),
};

match proto.status {
Some(ref status) => {
let key = HeaderName::from_str("Grpc-Message").unwrap();
let val = HeaderValue::from_str(&status.message).unwrap();
trailers.insert(key, val);
if let Some(ref status) = proto.status {
let key = HeaderName::from_str("Grpc-Message");
let val = HeaderValue::from_str(status.message.trim());
match (key, val) {
(Ok(k), Ok(v)) => {
trailers.insert(k, v);
}
(Err(e), _) => log::error!("Error parsing HeaderName: {e}"),
(_, Err(e)) => log::error!("Error parsing HeaderValue: {e}"),
}
None => (),
}

let k = match HeaderName::from_str(status_name) {
Expand Down

0 comments on commit 22559a8

Please sign in to comment.