close method
Close the request for input. Returns the value of done.
Implementation
@override
Future<HttpClientResponse> close() async {
try {
final response = await _inner.close();
_metadata.stopwatch.stop();
// For non-error responses, capture immediately without body (no headers needed)
if (!HTTPIntegration._isErrorStatusCode(response.statusCode)) {
final res = reservation; // use start-time reservation only
if (res != null) {
_captureHTTPResponse(response, null, reservation: res);
}
return response;
}
// For 4xx/5xx responses, capture headers and wrap response to tee the stream and capture body
_captureRequestHeaders();
return _wrapResponseForTee(response, _integration,
_capturedHeaders ?? _metadata.getFilteredHeaders());
} catch (e) {
_metadata.stopwatch.stop();
// For network errors, capture headers if we have them
_captureRequestHeaders();
final res = reservation; // use start-time reservation only
if (res != null) {
_captureHTTPResponse(null, e, reservation: res);
}
rethrow;
}
}