beforeResponse method
Registers task to finish before this request's response is written.
For writes the next request from the same client must see — a session save, above all: once the response is out, the browser may already be following its redirect.
Implementation
void beforeResponse(Future<void> Function() task) {
(_beforeResponse ??= <Future<void> Function()>[]).add(task);
}