Skip to content

Commit 8992e6a

Browse files
committed
feat(body): upgrade to http-body 1.0.0-rc.2
1 parent 3e41a4e commit 8992e6a

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ futures-core = { version = "0.3", default-features = false }
2424
futures-channel = "0.3"
2525
futures-util = { version = "0.3", default-features = false }
2626
http = "0.2"
27-
http-body = "1.0.0-rc.1"
28-
http-body-util = { version = "0.1.0-rc.1", optional = true }
27+
http-body = "=1.0.0-rc.2"
28+
http-body-util = { version = "=0.1.0-rc.2", optional = true }
2929
httpdate = "1.0"
3030
httparse = "1.8"
3131
h2 = { version = "0.3.9", optional = true }
@@ -42,7 +42,7 @@ socket2 = { version = "0.4", optional = true }
4242

4343
[dev-dependencies]
4444
futures-util = { version = "0.3", default-features = false, features = ["alloc"] }
45-
http-body-util = "0.1.0-rc.1"
45+
http-body-util = "=0.1.0-rc.2"
4646
matches = "0.1"
4747
num_cpus = "1.0"
4848
pretty_env_logger = "0.4"

src/ffi/body.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ ffi_fn! {
6363
loop {
6464
match body.0.frame().await {
6565
Some(Ok(frame)) => {
66-
if frame.is_data() {
67-
return Ok(Some(hyper_buf(frame.into_data().unwrap())));
66+
if let Ok(data) = frame.into_data() {
67+
return Ok(Some(hyper_buf(data)));
6868
} else {
6969
continue;
7070
}
@@ -95,7 +95,7 @@ ffi_fn! {
9595
Box::into_raw(hyper_task::boxed(async move {
9696
while let Some(item) = body.0.frame().await {
9797
let frame = item?;
98-
if let Some(chunk) = frame.into_data() {
98+
if let Ok(chunk) = frame.into_data() {
9999
if HYPER_ITER_CONTINUE != func(userdata.0, &hyper_buf(chunk)) {
100100
return Err(crate::Error::new_user_aborted_by_callback());
101101
}

src/proto/h1/dispatch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ where
339339
*clear_body = true;
340340
crate::Error::new_user_body(e)
341341
})?;
342-
let chunk = if frame.is_data() {
343-
frame.into_data().unwrap()
342+
let chunk = if let Ok(data) = frame.into_data() {
343+
data
344344
} else {
345345
trace!("discarding non-data frame");
346346
continue;

src/proto/h2/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ where
156156
match ready!(me.stream.as_mut().poll_frame(cx)) {
157157
Some(Ok(frame)) => {
158158
if frame.is_data() {
159-
let chunk = frame.into_data().unwrap();
159+
let chunk = frame.into_data().unwrap_or_else(|_| unreachable!());
160160
let is_eos = me.stream.is_end_stream();
161161
trace!(
162162
"send body chunk: {} bytes, eos={}",
@@ -176,7 +176,7 @@ where
176176
// no more DATA, so give any capacity back
177177
me.body_tx.reserve_capacity(0);
178178
me.body_tx
179-
.send_trailers(frame.into_trailers().unwrap())
179+
.send_trailers(frame.into_trailers().unwrap_or_else(|_| unreachable!()))
180180
.map_err(crate::Error::new_body_write)?;
181181
return Poll::Ready(Ok(()));
182182
} else {

0 commit comments

Comments
 (0)