onResponse method
Handles httpClientRequest and adds response to http alice call
Implementation
Future<void> onResponse(
HttpClientResponse response,
HttpClientRequest request, {
dynamic body,
}) async {
final httpResponse = AliceHttpResponse()..status = response.statusCode;
if (body != null) {
httpResponse
..body = body
..size = utf8.encode(body.toString()).length;
} else {
httpResponse
..body = ''
..size = 0;
}
httpResponse.time = DateTime.now();
final headers = <String, String>{};
response.headers.forEach((header, values) {
headers[header] = values.toString();
});
httpResponse.headers = headers;
aliceCore.addResponse(httpResponse, request.hashCode);
}