send method
Sends this request.
This automatically initializes a new Client and closes that client once
the request is complete. If you're planning on making multiple requests to
the same server, you should use a single Client for all of those
requests.
Implementation
@override
Future<FetchResponse> send() async {
final client = FetchClient();
try {
final response = await client.send(this);
final stream = onDone(response.stream, client.close);
return FetchResponse(
stream,
response.statusCode,
cancel: response.cancel,
url: response.url,
redirected: response.redirected,
request: response.request,
headers: response.headers,
isRedirect: response.isRedirect,
persistentConnection: response.persistentConnection,
reasonPhrase: response.reasonPhrase,
contentLength: response.contentLength,
);
} catch(_) {
client.close();
rethrow;
}
}