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