sendPushPromise method
Http3PushPromiseFrame
sendPushPromise(
- int pushId,
- Http3Request promisedRequest, {
- required int requestStreamId,
Send a PUSH_PROMISE frame on the client's request stream
(requestStreamId) reserving pushId for a server push of
promisedRequest.
Per RFC 9114 ยง4.4, the server sends a PUSH_PROMISE frame on the request
stream carrying the promised request's encoded header block. The promised
request headers are QPACK-encoded with this connection's qpackEncoder.
The frame is staged in getPendingPushPromises for transmission and the
push is registered so that hasPushPromise returns true for pushId.
The caller is responsible for ensuring that pushId does not exceed the
client's advertised MAX_PUSH_ID limit.
Returns the Http3PushPromiseFrame that was staged.
Implementation
Http3PushPromiseFrame sendPushPromise(
int pushId,
Http3Request promisedRequest, {
required int requestStreamId,
}) {
final encodedHeaders = promisedRequest.encodeHeaders(encoder: qpackEncoder);
final frame = Http3PushPromiseFrame(
pushId: pushId,
encodedFieldSection: encodedHeaders,
);
_pushPromises[pushId] = frame;
_pendingPushPromises.putIfAbsent(requestStreamId, () => []).add(frame);
_pendingQuicPackets.add(frame.toFrame().serialize());
return frame;
}