Work on prioritization

This commit is contained in:
Carl Lerche
2017-08-11 21:57:44 -07:00
parent 3b2ad536d9
commit 570962353b
4 changed files with 125 additions and 56 deletions

View File

@@ -1,13 +1,12 @@
pub mod support;
use support::*;
use h2::Frame;
#[test]
#[ignore]
fn single_stream_send_large_body() {
let _ = ::env_logger::init();
let payload = [0; 1024];
let mock = mock_io::Builder::new()
.handshake()
.write(&[
@@ -17,54 +16,78 @@ fn single_stream_send_large_body() {
])
.write(&[
// DATA
0, 0, 5, 0, 1, 0, 0, 0, 1, 104, 101, 108, 108, 111,
0, 4, 0, 0, 1, 0, 0, 0, 1,
])
.write(&payload[..])
.write(frames::SETTINGS_ACK)
// Read response
.read(&[
// HEADERS
0, 0, 1, 1, 4, 0, 0, 0, 1, 136,
// DATA
0, 0, 5, 0, 1, 0, 0, 0, 1, 119, 111, 114, 108, 100
])
.read(&[0, 0, 1, 1, 5, 0, 0, 0, 1, 0x89])
.build();
/*
let h2 = client::handshake(mock)
let mut h2 = Client::handshake(mock)
.wait().unwrap();
// Send the request
let mut request = request::Head::default();
request.method = method::POST;
request.uri = "https://http2.akamai.com/".parse().unwrap();
let h2 = h2.send_request(1.into(), request, false).wait().unwrap();
let request = Request::builder()
.method(method::POST)
.uri("https://http2.akamai.com/")
.body(()).unwrap();
let mut stream = h2.request(request, false).unwrap();
// Send the data
let b = [0; 300];
let h2 = h2.send_data(1.into(), (&b[..]).into(), true).wait().unwrap();
stream.send_data(payload[..].into(), true).unwrap();
// Get the response headers
let (resp, h2) = h2.into_future().wait().unwrap();
// Get the response
let resp = h2.run(poll_fn(|| stream.poll_response())).unwrap();
assert_eq!(resp.status(), status::NO_CONTENT);
match resp.unwrap() {
Frame::Headers { headers, .. } => {
assert_eq!(headers.status, status::OK);
}
_ => panic!("unexpected frame"),
}
// Get the response body
let (data, h2) = h2.into_future().wait().unwrap();
match data.unwrap() {
Frame::Data { id, data, end_of_stream, .. } => {
assert_eq!(id, 1.into());
assert_eq!(data, &b"world"[..]);
assert!(end_of_stream);
}
_ => panic!("unexpected frame"),
}
assert!(Stream::wait(h2).next().is_none());;
*/
h2.wait().unwrap();
}
#[test]
fn single_stream_send_extra_large_body_multi_frames() {
let _ = ::env_logger::init();
let payload = vec![0; 32_768];
let mock = mock_io::Builder::new()
.handshake()
.write(&[
// POST /
0, 0, 16, 1, 4, 0, 0, 0, 1, 131, 135, 65, 139, 157, 41,
172, 75, 143, 168, 233, 25, 151, 33, 233, 132,
])
.write(&[
// DATA
0, 64, 0, 0, 0, 0, 0, 0, 1,
])
.write(&payload[0..16_384])
.write(frames::SETTINGS_ACK)
.write(&[
// DATA
0, 64, 0, 0, 1, 0, 0, 0, 1,
])
.write(&payload[16_384..])
// Read response
.read(&[0, 0, 1, 1, 5, 0, 0, 0, 1, 0x89])
.build();
let mut h2 = Client::handshake(mock)
.wait().unwrap();
let request = Request::builder()
.method(method::POST)
.uri("https://http2.akamai.com/")
.body(()).unwrap();
let mut stream = h2.request(request, false).unwrap();
// Send the data
stream.send_data(payload.into(), true).unwrap();
// Get the response
let resp = h2.run(poll_fn(|| stream.poll_response())).unwrap();
assert_eq!(resp.status(), status::NO_CONTENT);
h2.wait().unwrap();
}