feat: client (wip), still unstable for http2 due to alpn issues
This commit is contained in:
parent
f020ece60d
commit
a9f5e0ede5
15 changed files with 199 additions and 70 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use http::Response;
|
||||
use http_body_util::{combinators, BodyExt, Either, Empty, Full};
|
||||
use hyper::body::{Bytes, Incoming};
|
||||
|
||||
|
|
@ -6,6 +7,19 @@ pub(crate) type BoxBody = combinators::BoxBody<Bytes, hyper::Error>;
|
|||
/// Type for either passthrough body or given body type, specifically synthetic boxed body
|
||||
pub(crate) type IncomingOr<B> = Either<Incoming, B>;
|
||||
|
||||
/// helper function to build http response with passthrough body
|
||||
pub(crate) fn wrap_incoming_body_response<B>(response: Response<Incoming>) -> Response<IncomingOr<B>>
|
||||
where
|
||||
B: hyper::body::Body,
|
||||
{
|
||||
response.map(IncomingOr::Left)
|
||||
}
|
||||
|
||||
/// helper function to build http response with synthetic body
|
||||
pub(crate) fn wrap_synthetic_body_response<B>(response: Response<B>) -> Response<IncomingOr<B>> {
|
||||
response.map(IncomingOr::Right)
|
||||
}
|
||||
|
||||
/// helper function to build a empty body
|
||||
pub(crate) fn empty() -> BoxBody {
|
||||
Empty::<Bytes>::new().map_err(|never| match never {}).boxed()
|
||||
|
|
|
|||
|
|
@ -8,5 +8,7 @@ pub(crate) mod rt {
|
|||
}
|
||||
pub(crate) mod body {
|
||||
pub(crate) use super::body_incoming_like::IncomingLike;
|
||||
pub(crate) use super::body_type::{empty, full, BoxBody, IncomingOr};
|
||||
pub(crate) use super::body_type::{
|
||||
empty, full, wrap_incoming_body_response, wrap_synthetic_body_response, BoxBody, IncomingOr,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue