From 5bbb206031de2ba8055c1ddee1619053ff2d465e Mon Sep 17 00:00:00 2001 From: Manphil Date: Sat, 7 Dec 2024 16:37:13 +0800 Subject: [PATCH] fix: Fill GRPC_CONTENT_TYPE when handing recover errors --- tonic/src/transport/server/service/recover_error.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tonic/src/transport/server/service/recover_error.rs b/tonic/src/transport/server/service/recover_error.rs index 57bdf8658..567c5222a 100644 --- a/tonic/src/transport/server/service/recover_error.rs +++ b/tonic/src/transport/server/service/recover_error.rs @@ -1,3 +1,4 @@ +use crate::metadata::GRPC_CONTENT_TYPE; use crate::Status; use http::Response; use http_body::Frame; @@ -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); status.add_header(res.headers_mut()).unwrap(); Poll::Ready(Ok(res)) }