@@ -622,47 +622,57 @@ impl<S, B> RequestStream<S, B>
622
622
where
623
623
S : quic:: RecvStream ,
624
624
{
625
- /// Receive some of the request body.
626
- pub async fn recv_data ( & mut self ) -> Result < Option < impl Buf > , Error > {
625
+ pub fn poll_data ( & mut self , cx : & mut Context < ' _ > ) -> Poll < Result < Option < impl Buf > , Error > > {
627
626
if !self . stream . has_data ( ) {
628
- let frame = future:: poll_fn ( |cx| self . stream . poll_next ( cx) )
629
- . await
630
- . map_err ( |e| self . maybe_conn_err ( e) ) ?;
631
- match frame {
632
- Some ( Frame :: Data { .. } ) => ( ) ,
633
- Some ( Frame :: Headers ( encoded) ) => {
634
- self . trailers = Some ( encoded) ;
635
- return Ok ( None ) ;
636
- }
627
+ match self . stream . poll_next ( cx) {
628
+ Poll :: Ready ( Ok ( frame) ) => {
629
+ match frame {
630
+ Some ( Frame :: Data { .. } ) => ( ) ,
631
+ Some ( Frame :: Headers ( encoded) ) => {
632
+ self . trailers = Some ( encoded) ;
633
+ return Poll :: Ready ( Ok ( None ) ) ;
634
+ }
637
635
638
- //= https://www.rfc-editor.org/rfc/rfc9114#section-4.1
639
- //# Receipt of an invalid sequence of frames MUST be treated as a
640
- //# connection error of type H3_FRAME_UNEXPECTED.
636
+ //= https://www.rfc-editor.org/rfc/rfc9114#section-4.1
637
+ //# Receipt of an invalid sequence of frames MUST be treated as a
638
+ //# connection error of type H3_FRAME_UNEXPECTED.
641
639
642
- //= https://www.rfc-editor.org/rfc/rfc9114#section-7.2.3
643
- //# Receiving a
644
- //# CANCEL_PUSH frame on a stream other than the control stream MUST be
645
- //# treated as a connection error of type H3_FRAME_UNEXPECTED.
640
+ //= https://www.rfc-editor.org/rfc/rfc9114#section-7.2.3
641
+ //# Receiving a
642
+ //# CANCEL_PUSH frame on a stream other than the control stream MUST be
643
+ //# treated as a connection error of type H3_FRAME_UNEXPECTED.
646
644
647
- //= https://www.rfc-editor.org/rfc/rfc9114#section-7.2.4
648
- //# If an endpoint receives a SETTINGS frame on a different
649
- //# stream, the endpoint MUST respond with a connection error of type
650
- //# H3_FRAME_UNEXPECTED.
651
-
652
- //= https://www.rfc-editor.org/rfc/rfc9114#section-7.2.6
653
- //# A client MUST treat a GOAWAY frame on a stream other than
654
- //# the control stream as a connection error of type H3_FRAME_UNEXPECTED.
655
-
656
- //= https://www.rfc-editor.org/rfc/rfc9114#section-7.2.7
657
- //# The MAX_PUSH_ID frame is always sent on the control stream. Receipt
658
- //# of a MAX_PUSH_ID frame on any other stream MUST be treated as a
659
- //# connection error of type H3_FRAME_UNEXPECTED.
660
- Some ( _) => return Err ( Code :: H3_FRAME_UNEXPECTED . into ( ) ) ,
661
- None => return Ok ( None ) ,
645
+ //= https://www.rfc-editor.org/rfc/rfc9114#section-7.2.4
646
+ //# If an endpoint receives a SETTINGS frame on a different
647
+ //# stream, the endpoint MUST respond with a connection error of type
648
+ //# H3_FRAME_UNEXPECTED.
649
+
650
+ //= https://www.rfc-editor.org/rfc/rfc9114#section-7.2.6
651
+ //# A client MUST treat a GOAWAY frame on a stream other than
652
+ //# the control stream as a connection error of type H3_FRAME_UNEXPECTED.
653
+
654
+ //= https://www.rfc-editor.org/rfc/rfc9114#section-7.2.7
655
+ //# The MAX_PUSH_ID frame is always sent on the control stream. Receipt
656
+ //# of a MAX_PUSH_ID frame on any other stream MUST be treated as a
657
+ //# connection error of type H3_FRAME_UNEXPECTED.
658
+ Some ( _) => return Poll :: Ready ( Err ( Code :: H3_FRAME_UNEXPECTED . into ( ) ) ) ,
659
+ None => return Poll :: Ready ( Ok ( None ) ) ,
660
+ }
661
+ }
662
+ Poll :: Ready ( Err ( e) ) => return Poll :: Ready ( Err ( self . maybe_conn_err ( e) ) ) ,
663
+ Poll :: Pending => return Poll :: Pending ,
662
664
}
663
665
}
666
+ match self . stream . poll_data ( cx) {
667
+ Poll :: Ready ( Ok ( data) ) => Poll :: Ready ( Ok ( data) ) ,
668
+ Poll :: Ready ( Err ( e) ) => Poll :: Ready ( Err ( self . maybe_conn_err ( e) ) ) ,
669
+ Poll :: Pending => Poll :: Pending ,
670
+ }
671
+ }
664
672
665
- let data = future:: poll_fn ( |cx| self . stream . poll_data ( cx) )
673
+ /// Receive some of the request body.
674
+ pub async fn recv_data ( & mut self ) -> Result < Option < impl Buf > , Error > {
675
+ let data = future:: poll_fn ( |cx| self . poll_data ( cx) )
666
676
. await
667
677
. map_err ( |e| self . maybe_conn_err ( e) ) ?;
668
678
Ok ( data)
0 commit comments