From e1993877c430906500aeda9ab1e3413e68ed483d Mon Sep 17 00:00:00 2001 From: gmorer Date: Wed, 2 Jun 2021 13:59:11 +0200 Subject: [PATCH] fix(web): fix compilation (#670) Make tonic::body::empty_body public and use it instead of the old and non existant anymore BoxBody::empty() --- tonic-web/tonic-web/src/service.rs | 6 +++--- tonic/src/body.rs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tonic-web/tonic-web/src/service.rs b/tonic-web/tonic-web/src/service.rs index df7a14988..4b87baeb4 100644 --- a/tonic-web/tonic-web/src/service.rs +++ b/tonic-web/tonic-web/src/service.rs @@ -2,7 +2,7 @@ use std::task::{Context, Poll}; use http::{header, HeaderMap, HeaderValue, Method, Request, Response, StatusCode, Version}; use hyper::Body; -use tonic::body::BoxBody; +use tonic::body::{BoxBody, empty_body}; use tonic::transport::NamedService; use tower_service::Service; use tracing::{debug, trace}; @@ -65,7 +65,7 @@ where fn no_content(&self, headers: HeaderMap) -> BoxFuture { let mut res = Response::builder() .status(StatusCode::NO_CONTENT) - .body(BoxBody::empty()) + .body(empty_body()) .unwrap(); res.headers_mut().extend(headers); @@ -77,7 +77,7 @@ where Box::pin(async move { Ok(Response::builder() .status(status) - .body(BoxBody::empty()) + .body(empty_body()) .unwrap()) }) } diff --git a/tonic/src/body.rs b/tonic/src/body.rs index 9f5f35b2d..ae1cb87eb 100644 --- a/tonic/src/body.rs +++ b/tonic/src/body.rs @@ -7,6 +7,7 @@ pub type BoxBody = http_body::combinators::BoxBody; // this also exists in `crate::codegen` but we need it here since `codegen` has // `#[cfg(feature = "codegen")]`. -pub(crate) fn empty_body() -> BoxBody { +/// Create an empty `BoxBody` +pub fn empty_body() -> BoxBody { http_body::Empty::new().map_err(|err| match err {}).boxed() }