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

        let mut reqs = Vec::new();

        let (stream1, req1) = s.send_request(false).unwrap();
        assert_eq!(stream1, 0);
        reqs.push(req1);

        let (stream2, req2) = s.send_request(false).unwrap();
        assert_eq!(stream2, 4);
        reqs.push(req2);

        let (stream3, req3) = s.send_request(false).unwrap();
        assert_eq!(stream3, 8);
        reqs.push(req3);

        let body = s.send_body_client(stream1, false).unwrap();
        s.send_body_client(stream2, false).unwrap();
        s.send_body_client(stream3, false).unwrap();

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

        // Reverse order of writes.

        s.send_body_client(stream3, true).unwrap();
        s.send_body_client(stream2, true).unwrap();
        s.send_body_client(stream1, true).unwrap();

        for _ in 0..reqs.len() {
            let (stream, ev) = s.poll_server().unwrap();
            let ev_headers = Event::Headers {
                list: reqs[(stream / 4) as usize].clone(),
                has_body: true,
            };
            assert_eq!(ev, ev_headers);
            assert_eq!(s.poll_server(), Ok((stream, Event::Data)));
            assert_eq!(s.recv_body_server(stream, &mut recv_buf), Ok(body.len()));
            assert_eq!(s.poll_client(), Err(Error::Done));

            assert_eq!(s.recv_body_server(stream, &mut recv_buf), Ok(body.len()));
            assert_eq!(s.poll_server(), Ok((stream, Event::Finished)));
        }

        assert_eq!(s.poll_server(), Err(Error::Done));

        let mut resps = Vec::new();

        let resp1 = s.send_response(stream1, true).unwrap();
        resps.push(resp1);

        let resp2 = s.send_response(stream2, true).unwrap();
        resps.push(resp2);

        let resp3 = s.send_response(stream3, true).unwrap();
        resps.push(resp3);

        for _ in 0..resps.len() {
            let (stream, ev) = s.poll_client().unwrap();
            let ev_headers = Event::Headers {
                list: resps[(stream / 4) as usize].clone(),
                has_body: false,
            };
            assert_eq!(ev, ev_headers);
            assert_eq!(s.poll_client(), Ok((stream, Event::Finished)));
        }

        assert_eq!(s.poll_client(), Err(Error::Done));
    }
/// Send a request with multiple DATA frames, get a response with one DATA
/// frame.
Send a request with multiple DATA frames, get a response with one DATA
frame.
Send a request with multiple DATA frames get a response with one DATA frame .
fn many_requests_many_chunks_response_one_chunk() {
        let mut s = Session::default().unwrap();
        s.handshake().unwrap();
        let mut reqs = Vec::new();
        let (stream1, req1) = s.send_request(false).unwrap();
        assert_eq!(stream1, 0);
        reqs.push(req1);
        let (stream2, req2) = s.send_request(false).unwrap();
        assert_eq!(stream2, 4);
        reqs.push(req2);
        let (stream3, req3) = s.send_request(false).unwrap();
        assert_eq!(stream3, 8);
        reqs.push(req3);
        let body = s.send_body_client(stream1, false).unwrap();
        s.send_body_client(stream2, false).unwrap();
        s.send_body_client(stream3, false).unwrap();
        let mut recv_buf = vec![0; body.len()];
        // Reverse order of writes.
        s.send_body_client(stream3, true).unwrap();
        s.send_body_client(stream2, true).unwrap();
        s.send_body_client(stream1, true).unwrap();
        for _ in 0..reqs.len() {
            let (stream, ev) = s.poll_server().unwrap();
            let ev_headers = Event::Headers {
                list: reqs[(stream / 4) as usize].clone(),
                has_body: true,
            };
            assert_eq!(ev, ev_headers);
            assert_eq!(s.poll_server(), Ok((stream, Event::Data)));
            assert_eq!(s.recv_body_server(stream, &mut recv_buf), Ok(body.len()));
            assert_eq!(s.poll_client(), Err(Error::Done));
            assert_eq!(s.recv_body_server(stream, &mut recv_buf), Ok(body.len()));
            assert_eq!(s.poll_server(), Ok((stream, Event::Finished)));
        }
        assert_eq!(s.poll_server(), Err(Error::Done));
        let mut resps = Vec::new();
        let resp1 = s.send_response(stream1, true).unwrap();
        resps.push(resp1);
        let resp2 = s.send_response(stream2, true).unwrap();
        resps.push(resp2);
        let resp3 = s.send_response(stream3, true).unwrap();
        resps.push(resp3);
        for _ in 0..resps.len() {
            let (stream, ev) = s.poll_client().unwrap();
            let ev_headers = Event::Headers {
                list: resps[(stream / 4) as usize].clone(),
                has_body: false,
            };
            assert_eq!(ev, ev_headers);
            assert_eq!(s.poll_client(), Ok((stream, Event::Finished)));
        }
        assert_eq!(s.poll_client(), Err(Error::Done));
    }
fn many_requests_many_chunks_response_one_chunk ( ) { let mut s = Session :: default ( ) . unwrap ( ) ; s . handshake ( ) . unwrap ( ) ; let mut reqs = Vec :: new ( ) ; let ( stream1 , req1 ) = s . send_request ( false ) . unwrap ( ) ; assert_eq ! ( stream1 0 ) ; reqs . push ( req1 ) ; let ( stream2 , req2 ) = s . send_request ( false ) . unwrap ( ) ; assert_eq ! ( stream2 4 ) ; reqs . push ( req2 ) ; let ( stream3 , req3 ) = s . send_request ( false ) . unwrap ( ) ; assert_eq ! ( stream3 8 ) ; reqs . push ( req3 ) ; let body = s . send_body_client ( stream1 , false ) . unwrap ( ) ; s . send_body_client ( stream2 , false ) . unwrap ( ) ; s . send_body_client ( stream3 , false ) . unwrap ( ) ; let mut recv_buf = vec ! [ 0 body len ( ) ] ; // Reverse order of writes. s . send_body_client ( stream3 , true ) . unwrap ( ) ; s . send_body_client ( stream2 , true ) . unwrap ( ) ; s . send_body_client ( stream1 , true ) . unwrap ( ) ; for _ in 0 .. reqs . len ( ) { let ( stream , ev ) = s . poll_server ( ) . unwrap ( ) ; let ev_headers = Event :: Headers { list : reqs [ ( stream / 4 ) as usize ] . clone ( ) , has_body : true , } ; assert_eq ! ( ev ev_headers ) ; assert_eq ! ( s poll_server ( ) Ok ( ( stream Event Data ) ) ) ; assert_eq ! ( s recv_body_server ( stream mut recv_buf ) Ok ( body len ( ) ) ) ; assert_eq ! ( s poll_client ( ) Err ( Error Done ) ) ; assert_eq ! ( s recv_body_server ( stream mut recv_buf ) Ok ( body len ( ) ) ) ; assert_eq ! ( s poll_server ( ) Ok ( ( stream Event Finished ) ) ) ; } assert_eq ! ( s poll_server ( ) Err ( Error Done ) ) ; let mut resps = Vec :: new ( ) ; let resp1 = s . send_response ( stream1 , true ) . unwrap ( ) ; resps . push ( resp1 ) ; let resp2 = s . send_response ( stream2 , true ) . unwrap ( ) ; resps . push ( resp2 ) ; let resp3 = s . send_response ( stream3 , true ) . unwrap ( ) ; resps . push ( resp3 ) ; for _ in 0 .. resps . len ( ) { let ( stream , ev ) = s . poll_client ( ) . unwrap ( ) ; let ev_headers = Event :: Headers { list : resps [ ( stream / 4 ) as usize ] . clone ( ) , has_body : false , } ; assert_eq ! ( ev ev_headers ) ; assert_eq ! ( s poll_client ( ) Ok ( ( stream Event Finished ) ) ) ; } assert_eq ! ( s poll_client ( ) Err ( Error Done ) ) ; }
Send a request with multiple DATA frames, get a response with one DATA
frame.
Send a request with multiple DATA frames get a response with one DATA frame .