@@ -5,18 +5,16 @@ use std::pin::Pin;
55use std:: task:: { Context , Poll } ;
66
77use bytes:: Bytes ;
8- #[ cfg( all( feature = "http1" , any( feature = "client" , feature = "server" ) ) ) ]
9- use futures_channel:: { mpsc, oneshot} ;
108#[ cfg( all(
119 any( feature = "http1" , feature = "http2" ) ,
1210 any( feature = "client" , feature = "server" )
1311) ) ]
1412use futures_core:: ready;
1513#[ cfg( all( feature = "http1" , any( feature = "client" , feature = "server" ) ) ) ]
16- use futures_core:: { stream:: FusedStream , Stream } ; // for mpsc::Receiver
17- #[ cfg( all( feature = "http1" , any( feature = "client" , feature = "server" ) ) ) ]
1814use http:: HeaderMap ;
1915use http_body:: { Body , Frame , SizeHint } ;
16+ #[ cfg( all( feature = "http1" , any( feature = "client" , feature = "server" ) ) ) ]
17+ use tokio:: sync:: { mpsc, oneshot} ;
2018
2119#[ cfg( all(
2220 any( feature = "http1" , feature = "http2" ) ,
@@ -219,8 +217,8 @@ impl Body for Incoming {
219217 } => {
220218 want_tx. send ( WANT_READY ) ;
221219
222- if !data_rx. is_terminated ( ) {
223- if let Some ( chunk) = ready ! ( Pin :: new( data_rx) . poll_next ( cx) ?) {
220+ if !data_rx. is_closed ( ) {
221+ if let Some ( chunk) = ready ! ( Pin :: new( data_rx) . poll_recv ( cx) ?) {
224222 len. sub_if ( chunk. len ( ) as u64 ) ;
225223 return Poll :: Ready ( Some ( Ok ( Frame :: data ( chunk) ) ) ) ;
226224 }
@@ -353,9 +351,11 @@ impl Sender {
353351 pub ( crate ) fn poll_ready ( & mut self , cx : & mut Context < ' _ > ) -> Poll < crate :: Result < ( ) > > {
354352 // Check if the receiver end has tried polling for the body yet
355353 ready ! ( self . poll_want( cx) ?) ;
356- self . data_tx
357- . poll_ready ( cx)
358- . map_err ( |_| crate :: Error :: new_closed ( ) )
354+ if self . data_tx . capacity ( ) > 0 {
355+ Poll :: Ready ( Ok ( ( ) ) )
356+ } else {
357+ Poll :: Pending
358+ }
359359 }
360360
361361 fn poll_want ( & mut self , cx : & mut Context < ' _ > ) -> Poll < crate :: Result < ( ) > > {
0 commit comments