Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fill GRPC_CONTENT_TYPE when handing recover errors #2092

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tonic/src/transport/server/service/recover_error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::metadata::GRPC_CONTENT_TYPE;
use crate::Status;
use http::Response;
use http_body::Frame;
Expand Down Expand Up @@ -67,6 +68,8 @@ where
Err(err) => match Status::try_from_error(err) {
Ok(status) => {
let mut res = Response::new(MaybeEmptyBody::empty());
res.headers_mut()
.insert(http::header::CONTENT_TYPE, GRPC_CONTENT_TYPE);
Comment on lines +71 to +72
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status::into_http can be used instead of reimplementing the logic.

status.add_header(res.headers_mut()).unwrap();
Poll::Ready(Ok(res))
}
Expand Down
Loading