We use nghttp2's auto handling of window sizes.
Start out with window size set to 500K and we do two h2 streams (multiple megabytes) over a single connection from a local server.
- The first stream (1) is paused as soon as data arrives.
- The second stream (3) goes through and when it is done, unpauses the stream 1 transfer.
When pause is returned from the callback (on first invoke for stream 1), libcurl sets the
local window size for the stream to 0 (with nghttp2_session_set_local_window_size()).
This then makes us receive 500K of data to buffer in memory since we already promised the 500K -
but no more.
When unpaused, libcurl first deliver the 500K buffered data to the callback, then sets the local
window size for stream 1 to 500K again and continues. (Using nghttp2_session_set_local_window_size()
again.)
Setting the local window size to 500K and then reading back the local size again says the window size is zero and indeed no data will flow. It is stuck.
Instead if we set the local window size for stream 1 to 500K * 2 in the unpause, we get the flow going again and the rest of the data arrives. But now with a window size of 1000K which if we pause again will require twice the memory! Not a good situation.