@@ -4,7 +4,7 @@ use std::pin::Pin;
44
55use async_std:: io;
66use async_std:: io:: prelude:: * ;
7- use async_std:: task:: { ready , Context , Poll } ;
7+ use async_std:: task:: { Context , Poll } ;
88use http_types:: Response ;
99
1010use crate :: chunked:: ChunkedEncoder ;
@@ -197,14 +197,22 @@ impl Encoder {
197197 buf : & mut [ u8 ] ,
198198 ) -> Poll < io:: Result < usize > > {
199199 let buf = & mut buf[ self . bytes_read ..] ;
200- let read = ready ! ( self . chunked. encode( & mut self . res, cx, buf) ) ?;
201-
202- self . bytes_read += read;
203- if self . bytes_read == 0 {
204- self . state = EncoderState :: Done
200+ match self . chunked . encode ( & mut self . res , cx, buf) {
201+ Poll :: Ready ( Ok ( read) ) => {
202+ self . bytes_read += read;
203+ if self . bytes_read == 0 {
204+ self . state = EncoderState :: Done
205+ }
206+ Poll :: Ready ( Ok ( self . bytes_read ) )
207+ }
208+ Poll :: Ready ( Err ( err) ) => Poll :: Ready ( Err ( err) ) ,
209+ Poll :: Pending => {
210+ if self . bytes_read > 0 {
211+ return Poll :: Ready ( Ok ( self . bytes_read ) ) ;
212+ }
213+ Poll :: Pending
214+ }
205215 }
206-
207- Poll :: Ready ( Ok ( self . bytes_read ) )
208216 }
209217}
210218
0 commit comments