Skip to content

Commit

Permalink
Make use of hyper::server::conn::http1::Builder::serve_buffered_conne…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
nox committed Jul 22, 2024
1 parent efd57ff commit b9c36e3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pretty_env_logger = "0.5"
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dev-dependencies]
pnet_datalink = "0.35.0"

[patch.crates-io]
hyper = { git = "https://github.com/hyperium/hyper.git", rev = "6c0d05e40d6bbd8739fc2ef5fecdc4690f083a83" }

[features]
default = []

Expand Down
6 changes: 3 additions & 3 deletions src/common/rewind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ impl<T> Rewind<T> {
self.pre = Some(bs);
}

// pub(crate) fn into_inner(self) -> (T, Bytes) {
// (self.inner, self.pre.unwrap_or_else(Bytes::new))
// }
pub(crate) fn into_inner(self) -> (T, Bytes) {
(self.inner, self.pre.unwrap_or_else(Bytes::new))
}

// pub(crate) fn get_mut(&mut self) -> &mut T {
// &mut self.inner
Expand Down
15 changes: 10 additions & 5 deletions src/server/conn/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ impl<E> Builder<E> {
let state = match self.version {
#[cfg(feature = "http1")]
Some(Version::H1) => {
let io = Rewind::new_buffered(io, Bytes::new());
let conn = self.http1.serve_connection(io, service);
ConnState::H1 { conn }
}
Expand Down Expand Up @@ -309,7 +308,7 @@ impl<'a, T> std::ops::Deref for Cow<'a, T> {
}

#[cfg(feature = "http1")]
type Http1Connection<I, S> = hyper::server::conn::http1::Connection<Rewind<I>, S>;
type Http1Connection<I, S> = hyper::server::conn::http1::Connection<I, S>;

#[cfg(not(feature = "http1"))]
type Http1Connection<I, S> = (PhantomData<I>, PhantomData<S>);
Expand Down Expand Up @@ -426,7 +425,10 @@ where
match version {
#[cfg(feature = "http1")]
Version::H1 => {
let conn = builder.http1.serve_connection(io, service);
let (io, buffered) = io.into_inner();
let conn = builder
.http1
.serve_buffered_connection(buffered, io, service);
this.state.set(ConnState::H1 { conn });
}
#[cfg(feature = "http2")]
Expand Down Expand Up @@ -484,7 +486,7 @@ pin_project! {
},
H1 {
#[pin]
conn: Http1UpgradeableConnection<Rewind<I>, S>,
conn: Http1UpgradeableConnection<I, S>,
},
H2 {
#[pin]
Expand Down Expand Up @@ -576,7 +578,10 @@ where
match version {
#[cfg(feature = "http1")]
Version::H1 => {
let conn = builder.http1.serve_connection(io, service).with_upgrades();
let (io, buffered) = io.into_inner();
let conn = builder
.http1
.serve_buffered_connection(buffered, io, service).with_upgrades();
this.state.set(UpgradeableConnState::H1 { conn });
}
#[cfg(feature = "http2")]
Expand Down

0 comments on commit b9c36e3

Please sign in to comment.