Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of Builder::serve_buffered_connection #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 11 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,11 @@ 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