closeResponse method
Ends a stream the driver wrote to (see _pending). A stream it never
wrote to is reset instead, since no valid response can be sent on it, as
is one whose Http2ResponseContext sent its own headers but not those of
the driver (e.g. an error fallback after a response started streaming).
Implementation
@override
Future closeResponse(ServerTransportStream response) {
var pending = _pending[response];
if (pending == null ||
(!pending.sent && Http2ResponseContext.sentHeaders(response))) {
response.terminate();
} else if (!pending.closed) {
pending.closed = true;
if (pending.sent) {
return response.outgoingMessages.close();
}
pending.sent = true;
response.sendHeaders(_headersOf(pending), endStream: true);
}
return Future.value();
}