fn stream_backpressure() {
        let bytes = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

        let mut s = Session::default().unwrap();
        s.handshake().unwrap();

        let (stream, req) = s.send_request(false).unwrap();

        let total_data_frames = 6;

        for _ in 0..total_data_frames {
            assert_eq!(
                s.client
                    .send_body(&mut s.pipe.client, stream, &bytes, false),
                Ok(bytes.len())
            );

            s.advance().ok();
        }

        assert_eq!(
            s.client.send_body(&mut s.pipe.client, stream, &bytes, true),
            Ok(bytes.len() - 2)
        );

        s.advance().ok();

        let mut recv_buf = vec![0; bytes.len()];

        let ev_headers = Event::Headers {
            list: req,
            has_body: true,
        };

        assert_eq!(s.poll_server(), Ok((stream, ev_headers)));
        assert_eq!(s.poll_server(), Ok((stream, Event::Data)));
        assert_eq!(s.poll_server(), Err(Error::Done));

        for _ in 0..total_data_frames {
            assert_eq!(
                s.recv_body_server(stream, &mut recv_buf),
                Ok(bytes.len())
            );
        }

        assert_eq!(
            s.recv_body_server(stream, &mut recv_buf),
            Ok(bytes.len() - 2)
        );

        // Fin flag from last send_body() call was not sent as the buffer was
        // only partially written.
        assert_eq!(s.poll_server(), Err(Error::Done));
    }
/// Tests that DATA frames are properly truncated depending on the request
/// stream's outgoing flow control capacity.
Tests that DATA frames are properly truncated depending on the request
stream's outgoing flow control capacity.
Tests that DATA frames are properly truncated depending on the request stream ' s outgoing flow control capacity .
fn stream_backpressure() {
        let bytes = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
        let mut s = Session::default().unwrap();
        s.handshake().unwrap();
        let (stream, req) = s.send_request(false).unwrap();
        let total_data_frames = 6;
        for _ in 0..total_data_frames {
            assert_eq!(
                s.client
                    .send_body(&mut s.pipe.client, stream, &bytes, false),
                Ok(bytes.len())
            );
            s.advance().ok();
        }
        assert_eq!(
            s.client.send_body(&mut s.pipe.client, stream, &bytes, true),
            Ok(bytes.len() - 2)
        );
        s.advance().ok();
        let mut recv_buf = vec![0; bytes.len()];
        let ev_headers = Event::Headers {
            list: req,
            has_body: true,
        };
        assert_eq!(s.poll_server(), Ok((stream, ev_headers)));
        assert_eq!(s.poll_server(), Ok((stream, Event::Data)));
        assert_eq!(s.poll_server(), Err(Error::Done));
        for _ in 0..total_data_frames {
            assert_eq!(
                s.recv_body_server(stream, &mut recv_buf),
                Ok(bytes.len())
            );
        }
        assert_eq!(
            s.recv_body_server(stream, &mut recv_buf),
            Ok(bytes.len() - 2)
        );
        // Fin flag from last send_body() call was not sent as the buffer was
        // only partially written.
        assert_eq!(s.poll_server(), Err(Error::Done));
    }
fn stream_backpressure ( ) { let bytes = vec ! [ 1 2 3 4 5 6 7 8 9 10 ] ; let mut s = Session :: default ( ) . unwrap ( ) ; s . handshake ( ) . unwrap ( ) ; let ( stream , req ) = s . send_request ( false ) . unwrap ( ) ; let total_data_frames = 6 ; for _ in 0 .. total_data_frames { assert_eq ! ( s client send_body ( mut s pipe client stream bytes false ) Ok ( bytes len ( ) ) ) ; s . advance ( ) . ok ( ) ; } assert_eq ! ( s client send_body ( mut s pipe client stream bytes true ) Ok ( bytes len ( ) 2 ) ) ; s . advance ( ) . ok ( ) ; let mut recv_buf = vec ! [ 0 bytes len ( ) ] ; let ev_headers = Event :: Headers { list : req , has_body : true , } ; assert_eq ! ( s poll_server ( ) Ok ( ( stream ev_headers ) ) ) ; assert_eq ! ( s poll_server ( ) Ok ( ( stream Event Data ) ) ) ; assert_eq ! ( s poll_server ( ) Err ( Error Done ) ) ; for _ in 0 .. total_data_frames { assert_eq ! ( s recv_body_server ( stream mut recv_buf ) Ok ( bytes len ( ) ) ) ; } assert_eq ! ( s recv_body_server ( stream mut recv_buf ) Ok ( bytes len ( ) 2 ) ) ; // Fin flag from last send_body() call was not sent as the buffer was // only partially written. assert_eq ! ( s poll_server ( ) Err ( Error Done ) ) ; }
Tests that DATA frames are properly truncated depending on the request
stream's outgoing flow control capacity.
Tests that DATA frames are properly truncated depending on the request stream ' s outgoing flow control capacity .