File tree 4 files changed +9
-9
lines changed
4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -557,7 +557,7 @@ impl Recv {
557
557
}
558
558
559
559
pub fn is_end_stream ( & self , stream : & store:: Ptr ) -> bool {
560
- if !stream. state . is_recv_closed ( ) {
560
+ if !stream. state . is_end_stream ( ) {
561
561
return false ;
562
562
}
563
563
Original file line number Diff line number Diff line change @@ -413,11 +413,8 @@ impl State {
413
413
matches ! ( self . inner, Closed ( _) )
414
414
}
415
415
416
- pub fn is_recv_closed ( & self ) -> bool {
417
- matches ! (
418
- self . inner,
419
- Closed ( ..) | HalfClosedRemote ( ..) | ReservedLocal
420
- )
416
+ pub fn is_end_stream ( & self ) -> bool {
417
+ matches ! ( self . inner, Closed ( Cause :: EndStream ) )
421
418
}
422
419
423
420
pub fn is_send_closed ( & self ) -> bool {
Original file line number Diff line number Diff line change 1
1
use bytes:: { BufMut , Bytes } ;
2
2
use futures:: ready;
3
+ use std:: borrow:: BorrowMut ;
3
4
use std:: future:: Future ;
4
5
use std:: pin:: Pin ;
5
6
use std:: task:: { Context , Poll } ;
@@ -8,7 +9,8 @@ pub fn byte_str(s: &str) -> h2::frame::BytesStr {
8
9
h2:: frame:: BytesStr :: try_from ( Bytes :: copy_from_slice ( s. as_bytes ( ) ) ) . unwrap ( )
9
10
}
10
11
11
- pub async fn concat ( mut body : h2:: RecvStream ) -> Result < Bytes , h2:: Error > {
12
+ pub async fn concat < B : BorrowMut < h2:: RecvStream > > ( mut body : B ) -> Result < Bytes , h2:: Error > {
13
+ let body = body. borrow_mut ( ) ;
12
14
let mut vec = Vec :: new ( ) ;
13
15
while let Some ( chunk) = body. data ( ) . await {
14
16
vec. put ( chunk?) ;
Original file line number Diff line number Diff line change @@ -338,13 +338,14 @@ async fn errors_if_recv_frame_exceeds_max_frame_size() {
338
338
let req = async move {
339
339
let resp = client. get ( "https://example.com/" ) . await . expect ( "response" ) ;
340
340
assert_eq ! ( resp. status( ) , StatusCode :: OK ) ;
341
- let body = resp. into_parts ( ) . 1 ;
342
- let res = util:: concat ( body) . await ;
341
+ let mut body = resp. into_parts ( ) . 1 ;
342
+ let res = util:: concat ( & mut body) . await ;
343
343
let err = res. unwrap_err ( ) ;
344
344
assert_eq ! (
345
345
err. to_string( ) ,
346
346
"connection error detected: frame with invalid size"
347
347
) ;
348
+ assert ! ( !body. is_end_stream( ) ) ;
348
349
} ;
349
350
350
351
// client should see a conn error
You can’t perform that action at this time.
0 commit comments