@@ -237,6 +237,7 @@ pub struct Connection<T, B: Buf = Bytes> {
237237#[ must_use = "futures do nothing unless polled" ]
238238pub struct ResponseFuture {
239239 inner : proto:: OpaqueStreamRef ,
240+ body : Option < proto:: OpaqueStreamRef > ,
240241 push_promise_consumed : bool ,
241242}
242243
@@ -517,15 +518,16 @@ where
517518 self . inner
518519 . send_request ( request, end_of_stream, self . pending . as_ref ( ) )
519520 . map_err ( Into :: into)
520- . map ( |( stream, is_full) | {
521+ . map ( |( stream, response , body , is_full) | {
521522 if stream. is_pending_open ( ) && is_full {
522523 // Only prevent sending another request when the request queue
523524 // is not full.
524525 self . pending = Some ( stream. clone_to_opaque ( ) ) ;
525526 }
526527
527528 let response = ResponseFuture {
528- inner : stream. clone_to_opaque ( ) ,
529+ inner : response,
530+ body : Some ( body) ,
529531 push_promise_consumed : false ,
530532 } ;
531533
@@ -1470,18 +1472,18 @@ impl Future for ResponseFuture {
14701472
14711473 fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
14721474 let ( parts, _) = ready ! ( self . inner. poll_response( cx) ) ?. into_parts ( ) ;
1473- let body = RecvStream :: new ( FlowControl :: new ( self . inner . clone ( ) ) ) ;
1475+ let body = RecvStream :: new ( FlowControl :: new (
1476+ self . body
1477+ . take ( )
1478+ . expect ( "ResponseFuture polled after completion" ) ,
1479+ ) ) ;
14741480
14751481 Poll :: Ready ( Ok ( Response :: from_parts ( parts, body) ) )
14761482 }
14771483}
14781484
14791485impl ResponseFuture {
14801486 /// Returns the stream ID of the response stream.
1481- ///
1482- /// # Panics
1483- ///
1484- /// If the lock on the stream store has been poisoned.
14851487 pub fn stream_id ( & self ) -> crate :: StreamId {
14861488 crate :: StreamId :: from_internal ( self . inner . stream_id ( ) )
14871489 }
@@ -1532,10 +1534,11 @@ impl PushPromises {
15321534 cx : & mut Context < ' _ > ,
15331535 ) -> Poll < Option < Result < PushPromise , crate :: Error > > > {
15341536 match self . inner . poll_pushed ( cx) {
1535- Poll :: Ready ( Some ( Ok ( ( request, response) ) ) ) => {
1537+ Poll :: Ready ( Some ( Ok ( ( request, response, body ) ) ) ) => {
15361538 let response = PushedResponseFuture {
15371539 inner : ResponseFuture {
15381540 inner : response,
1541+ body : Some ( body) ,
15391542 push_promise_consumed : false ,
15401543 } ,
15411544 } ;
@@ -1589,10 +1592,6 @@ impl Future for PushedResponseFuture {
15891592
15901593impl PushedResponseFuture {
15911594 /// Returns the stream ID of the response stream.
1592- ///
1593- /// # Panics
1594- ///
1595- /// If the lock on the stream store has been poisoned.
15961595 pub fn stream_id ( & self ) -> crate :: StreamId {
15971596 self . inner . stream_id ( )
15981597 }
0 commit comments