preparing nightly-build
This commit is contained in:
parent
92638ccd2a
commit
f41a2213f9
13 changed files with 109 additions and 110 deletions
|
|
@ -1,11 +1,12 @@
|
|||
use super::body::IncomingLike;
|
||||
use crate::error::RpxyError;
|
||||
use http_body_util::{combinators, BodyExt, Empty, Full};
|
||||
use hyper::body::{Body, Bytes, Incoming};
|
||||
use futures::channel::mpsc::UnboundedReceiver;
|
||||
use http_body_util::{combinators, BodyExt, Empty, Full, StreamBody};
|
||||
use hyper::body::{Body, Bytes, Frame, Incoming};
|
||||
use std::pin::Pin;
|
||||
|
||||
/// Type for synthetic boxed body
|
||||
pub(crate) type BoxBody = combinators::BoxBody<Bytes, hyper::Error>;
|
||||
pub type BoxBody = combinators::BoxBody<Bytes, hyper::Error>;
|
||||
|
||||
/// helper function to build a empty body
|
||||
pub(crate) fn empty() -> BoxBody {
|
||||
|
|
@ -17,11 +18,12 @@ pub(crate) fn full(body: Bytes) -> BoxBody {
|
|||
Full::new(body).map_err(|never| match never {}).boxed()
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
/* ------------------------------------ */
|
||||
/// Request body used in this project
|
||||
/// - Incoming: just a type that only forwards the downstream request body to upstream.
|
||||
/// - IncomingLike: a Incoming-like type in which channel is used
|
||||
pub(crate) enum RequestBody {
|
||||
pub enum RequestBody {
|
||||
Incoming(Incoming),
|
||||
IncomingLike(IncomingLike),
|
||||
}
|
||||
|
|
@ -42,24 +44,16 @@ impl Body for RequestBody {
|
|||
}
|
||||
|
||||
/* ------------------------------------ */
|
||||
#[cfg(feature = "cache")]
|
||||
use futures::channel::mpsc::UnboundedReceiver;
|
||||
#[cfg(feature = "cache")]
|
||||
use http_body_util::StreamBody;
|
||||
#[cfg(feature = "cache")]
|
||||
use hyper::body::Frame;
|
||||
|
||||
#[cfg(feature = "cache")]
|
||||
pub(crate) type UnboundedStreamBody = StreamBody<UnboundedReceiver<Result<Frame<bytes::Bytes>, hyper::Error>>>;
|
||||
pub type UnboundedStreamBody = StreamBody<UnboundedReceiver<Result<Frame<bytes::Bytes>, hyper::Error>>>;
|
||||
|
||||
#[allow(unused)]
|
||||
/// Response body use in this project
|
||||
/// - Incoming: just a type that only forwards the upstream response body to downstream.
|
||||
/// - Boxed: a type that is generated from cache or synthetic response body, e.g.,, small byte object.
|
||||
/// - Streamed: another type that is generated from stream, e.g., large byte object.
|
||||
pub(crate) enum ResponseBody {
|
||||
pub enum ResponseBody {
|
||||
Incoming(Incoming),
|
||||
Boxed(BoxBody),
|
||||
#[cfg(feature = "cache")]
|
||||
Streamed(UnboundedStreamBody),
|
||||
}
|
||||
|
||||
|
|
@ -73,9 +67,7 @@ impl Body for ResponseBody {
|
|||
) -> std::task::Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
|
||||
match self.get_mut() {
|
||||
ResponseBody::Incoming(incoming) => Pin::new(incoming).poll_frame(cx),
|
||||
#[cfg(feature = "cache")]
|
||||
ResponseBody::Boxed(boxed) => Pin::new(boxed).poll_frame(cx),
|
||||
#[cfg(feature = "cache")]
|
||||
ResponseBody::Streamed(streamed) => Pin::new(streamed).poll_frame(cx),
|
||||
}
|
||||
.map_err(RpxyError::HyperBodyError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue