http2 icon indicating copy to clipboard operation
http2 copied to clipboard

`getRequestBodyChunk` should indicate if a chunk is the last one

Open edsko opened this issue 3 months ago • 3 comments

For streaming calls, clients have two ways of indicating end-of-input to the sever:

NON-EMPTY DATA FRAME 1  <not marked as end-of-stream>
NON-EMPTY DATA FRAME 2  <not marked as end-of-stream>
NON-EMPTY DATA FRAME 3  <marked as end-of-stream>

and

NON-EMPTY DATA FRAME 1  <not marked as end-of-stream>
NON-EMPTY DATA FRAME 2  <not marked as end-of-stream>
NON-EMPTY DATA FRAME 3  <not marked as end-of-stream>
EMPTY DATA FRAME 4 <marked as end-of-stream>

getRequestBodyChunk does not allow servers to differentiate between these two cases; in both cases, we will first get a non-empty bytestring indicating the last piece of data, and then the next call to getRequestBodyChunk will return an empty bytestring. Calling getRequestBodyChunk again to figure out after-the-fact if the previously received bytestring was the final one is not an option, because that call may block. We therefore need a generalization that doesn't just give us a bytestring, but also tells us if that bytestring was marked being the last one.

For an example of where this matters, see https://github.com/well-typed/grapesy/issues/114 .

edsko avatar Mar 30 '24 08:03 edsko