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

feat(body): upgrade to http-body 1.0.0-rc.2 #3106

Merged
merged 1 commit into from Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -24,8 +24,8 @@ futures-core = { version = "0.3", default-features = false }
futures-channel = "0.3"
futures-util = { version = "0.3", default-features = false }
http = "0.2"
http-body = "1.0.0-rc.1"
http-body-util = { version = "0.1.0-rc.1", optional = true }
http-body = "=1.0.0-rc.2"
http-body-util = { version = "=0.1.0-rc.2", optional = true }
httpdate = "1.0"
httparse = "1.8"
h2 = { version = "0.3.9", optional = true }
Expand All @@ -42,7 +42,7 @@ socket2 = { version = "0.4", optional = true }

[dev-dependencies]
futures-util = { version = "0.3", default-features = false, features = ["alloc"] }
http-body-util = "0.1.0-rc.1"
http-body-util = "=0.1.0-rc.2"
matches = "0.1"
num_cpus = "1.0"
pretty_env_logger = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/echo.rs
Expand Up @@ -27,7 +27,7 @@ async fn echo(
// Convert to uppercase before sending back to client using a stream.
(&Method::POST, "/echo/uppercase") => {
let frame_stream = req.into_body().map_frame(|frame| {
let frame = if let Some(data) = frame.into_data() {
let frame = if let Ok(data) = frame.into_data() {
data.iter()
.map(|byte| byte.to_ascii_uppercase())
.collect::<Bytes>()
Expand Down
6 changes: 3 additions & 3 deletions src/ffi/body.rs
Expand Up @@ -63,8 +63,8 @@ ffi_fn! {
loop {
match body.0.frame().await {
Some(Ok(frame)) => {
if frame.is_data() {
return Ok(Some(hyper_buf(frame.into_data().unwrap())));
if let Ok(data) = frame.into_data() {
return Ok(Some(hyper_buf(data)));
} else {
continue;
}
Expand Down Expand Up @@ -95,7 +95,7 @@ ffi_fn! {
Box::into_raw(hyper_task::boxed(async move {
while let Some(item) = body.0.frame().await {
let frame = item?;
if let Some(chunk) = frame.into_data() {
if let Ok(chunk) = frame.into_data() {
if HYPER_ITER_CONTINUE != func(userdata.0, &hyper_buf(chunk)) {
return Err(crate::Error::new_user_aborted_by_callback());
}
Expand Down
4 changes: 2 additions & 2 deletions src/proto/h1/dispatch.rs
Expand Up @@ -339,8 +339,8 @@ where
*clear_body = true;
crate::Error::new_user_body(e)
})?;
let chunk = if frame.is_data() {
frame.into_data().unwrap()
let chunk = if let Ok(data) = frame.into_data() {
data
} else {
trace!("discarding non-data frame");
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/proto/h2/mod.rs
Expand Up @@ -156,7 +156,7 @@ where
match ready!(me.stream.as_mut().poll_frame(cx)) {
Some(Ok(frame)) => {
if frame.is_data() {
let chunk = frame.into_data().unwrap();
let chunk = frame.into_data().unwrap_or_else(|_| unreachable!());
let is_eos = me.stream.is_end_stream();
trace!(
"send body chunk: {} bytes, eos={}",
Expand All @@ -176,7 +176,7 @@ where
// no more DATA, so give any capacity back
me.body_tx.reserve_capacity(0);
me.body_tx
.send_trailers(frame.into_trailers().unwrap())
.send_trailers(frame.into_trailers().unwrap_or_else(|_| unreachable!()))
.map_err(crate::Error::new_body_write)?;
return Poll::Ready(Ok(()));
} else {
Expand Down