HttpResponse.factory constructor
HttpResponse.factory(
- String url,
- Response response
Implementation
factory HttpResponse.factory(String url, dart_http.Response response) {
// content type
String? contentType;
if (response.headers.containsKey(HttpHeaders.contentTypeHeader)) {
contentType = response.headers[HttpHeaders.contentTypeHeader];
}
dynamic body;
try {
body = utf8.decode(response.bodyBytes);
} catch (e) {
body = response.body;
}
return HttpResponse(url,
body: body,
bytes: response.bodyBytes,
contentType: contentType,
statusCode: response.statusCode,
statusMessage: response.reasonPhrase);
}