From 36bc21c59d9082e86eb3bbcd11b9277075001ef7 Mon Sep 17 00:00:00 2001 From: tottoto Date: Sat, 14 Dec 2024 13:14:30 +0900 Subject: [PATCH] fix(server): Use Status::into_http api in recover error service (#2099) --- tonic/src/transport/server/service/recover_error.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tonic/src/transport/server/service/recover_error.rs b/tonic/src/transport/server/service/recover_error.rs index 57bdf8658..7b89919b4 100644 --- a/tonic/src/transport/server/service/recover_error.rs +++ b/tonic/src/transport/server/service/recover_error.rs @@ -66,8 +66,8 @@ where } Err(err) => match Status::try_from_error(err) { Ok(status) => { - let mut res = Response::new(MaybeEmptyBody::empty()); - status.add_header(res.headers_mut()).unwrap(); + let (parts, ()) = status.into_http::<()>().into_parts(); + let res = Response::from_parts(parts, MaybeEmptyBody::empty()); Poll::Ready(Ok(res)) } Err(err) => Poll::Ready(Err(err)),