@@ -4,7 +4,7 @@ use std::pin::Pin;
4
4
5
5
use async_std:: io;
6
6
use async_std:: io:: prelude:: * ;
7
- use async_std:: task:: { ready , Context , Poll } ;
7
+ use async_std:: task:: { Context , Poll } ;
8
8
use http_types:: Response ;
9
9
10
10
use crate :: chunked:: ChunkedEncoder ;
@@ -197,14 +197,22 @@ impl Encoder {
197
197
buf : & mut [ u8 ] ,
198
198
) -> Poll < io:: Result < usize > > {
199
199
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
+ }
205
215
}
206
-
207
- Poll :: Ready ( Ok ( self . bytes_read ) )
208
216
}
209
217
}
210
218
0 commit comments