send method
Sends the HTTP request.
If client
is not provided, a short-lived one is created for this request.
Implementation
Future<AWSStreamedHttpResponse> send([http.Client? client]) async {
final useClient = client ?? http.Client();
// Closes the HTTP client, but only if we created it.
void closeClient() {
if (client == null) {
useClient.close();
}
}
try {
final resp = await useClient.send(httpRequest);
return AWSStreamedHttpResponse(
headers: resp.headers,
statusCode: resp.statusCode,
body: resp.stream.tap(
null,
// Wait until the body has been read before closing the client,
// since chunked requests require that the client not be closed
// until they're complete.
onDone: closeClient,
),
);
} on Object {
closeClient();
rethrow;
}
}