feat(body): change Sender::send_data to an async fn.

The previous version is renamed to `try_send_data`.

BREAKING CHANGE: Usage of `send_data` should either be changed to
  async/await or use `try_send_data`.
This commit is contained in:
Sean McArthur
2019-08-30 14:50:37 -07:00
parent 0331219b40
commit 62a96c077b
4 changed files with 20 additions and 11 deletions

View File

@@ -5,7 +5,6 @@ use http::{Request, Response, StatusCode};
use tokio_io::{AsyncRead, AsyncWrite};
use crate::body::{Body, Payload};
use crate::body::internal::FullDataArg;
use crate::common::{Future, Never, Poll, Pin, Unpin, task};
use crate::proto::{BodyLength, DecodedLength, Conn, Dispatched, MessageHead, RequestHead, RequestLine, ResponseHead};
use super::Http1Transaction;
@@ -169,7 +168,7 @@ where
}
match self.conn.poll_read_body(cx) {
Poll::Ready(Some(Ok(chunk))) => {
match body.send_data(chunk) {
match body.try_send_data(chunk) {
Ok(()) => {
self.body_tx = Some(body);
},
@@ -249,7 +248,7 @@ where
return Poll::Ready(Ok(()));
} else if self.body_rx.is_none() && self.conn.can_write_head() && self.dispatch.should_poll() {
if let Some(msg) = ready!(self.dispatch.poll_msg(cx)) {
let (head, mut body) = msg.map_err(crate::Error::new_user_service)?;
let (head, body) = msg.map_err(crate::Error::new_user_service)?;
let body_type = if body.is_end_stream() {
self.body_rx.set(None);