Skip to content

Commit

Permalink
tonic: optimize Status::add_header
Browse files Browse the repository at this point in the history
  • Loading branch information
srijs committed Apr 16, 2023
1 parent 3e16bf7 commit 2c83f31
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tonic/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use crate::body::BoxBody;
use crate::metadata::MetadataMap;
use base64::Engine as _;
use bytes::Bytes;
use http::header::{HeaderMap, HeaderValue};
use http::{
header::{HeaderMap, HeaderValue},
HeaderName,
};
use percent_encoding::{percent_decode, percent_encode, AsciiSet, CONTROLS};
use std::{borrow::Cow, error::Error, fmt, sync::Arc};
use tracing::{debug, trace, warn};
Expand All @@ -18,9 +21,9 @@ const ENCODING_SET: &AsciiSet = &CONTROLS
.add(b'{')
.add(b'}');

const GRPC_STATUS_HEADER_CODE: &str = "grpc-status";
const GRPC_STATUS_MESSAGE_HEADER: &str = "grpc-message";
const GRPC_STATUS_DETAILS_HEADER: &str = "grpc-status-details-bin";
const GRPC_STATUS_HEADER_CODE: HeaderName = HeaderName::from_static("grpc-status");
const GRPC_STATUS_MESSAGE_HEADER: HeaderName = HeaderName::from_static("grpc-message");
const GRPC_STATUS_DETAILS_HEADER: HeaderName = HeaderName::from_static("grpc-status-details-bin");

/// A gRPC status describing the result of an RPC call.
///
Expand Down

0 comments on commit 2c83f31

Please sign in to comment.