New send flow control (#25)
Restructure send flow control such that sending data is always accepted by `Stream`. Data frames will be buffered until there is available window to send them. Producers can monitor the available window capacity to decide if data should be produced.
This commit is contained in:
@@ -34,6 +34,12 @@ fn single_stream_send_large_body() {
|
||||
|
||||
let mut stream = h2.request(request, false).unwrap();
|
||||
|
||||
// Reserve capacity to send the payload
|
||||
stream.reserve_capacity(payload.len()).unwrap();
|
||||
|
||||
// The capacity should be immediately allocated
|
||||
assert_eq!(stream.capacity(), payload.len());
|
||||
|
||||
// Send the data
|
||||
stream.send_data(payload[..].into(), true).unwrap();
|
||||
|
||||
@@ -82,6 +88,11 @@ fn single_stream_send_extra_large_body_multi_frames_one_buffer() {
|
||||
|
||||
let mut stream = h2.request(request, false).unwrap();
|
||||
|
||||
stream.reserve_capacity(payload.len()).unwrap();
|
||||
|
||||
// The capacity should be immediately allocated
|
||||
assert_eq!(stream.capacity(), payload.len());
|
||||
|
||||
// Send the data
|
||||
stream.send_data(payload.into(), true).unwrap();
|
||||
|
||||
@@ -142,6 +153,11 @@ fn single_stream_send_extra_large_body_multi_frames_multi_buffer() {
|
||||
|
||||
let mut stream = h2.request(request, false).unwrap();
|
||||
|
||||
stream.reserve_capacity(payload.len()).unwrap();
|
||||
|
||||
// The capacity should be immediately allocated
|
||||
assert_eq!(stream.capacity(), payload.len());
|
||||
|
||||
// Send the data
|
||||
stream.send_data(payload.into(), true).unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user