replay method
Sends request. Completes when the response or the error was received.
Implementation
@override
Future<void> replay(NetLensReplayRequest request) async {
final HttpClient client = replayClient ?? HttpClient();
try {
final HttpClientRequest httpRequest = await client.openUrl(
request.method,
Uri.parse(request.url),
);
request.headers.forEach(httpRequest.headers.set);
if (request.body != null) {
httpRequest.write(request.body);
}
onRequest(httpRequest, body: request.body);
final HttpClientResponse response = await httpRequest.close();
final String responseBody = await utf8.decoder.bind(response).join();
await onResponse(response, httpRequest, body: responseBody);
} finally {
if (replayClient == null) {
client.close();
}
}
}