send method
Send request and return the resolved HttpResponse.
Implementation
@override
Future<HttpResponse> send(HttpRequest request) async {
recordedRequests.add(request);
for (final stub in _stubs) {
if (!stub.matches(request)) continue;
if (stub.delay != null) {
await Future<void>.delayed(stub.delay!);
}
final next = stub.next();
if (next.exception != null) throw next.exception!;
return next.response!;
}
throw HttpAdapterException(
kind: HttpAdapterErrorKind.unknown,
message: 'MockAdapter: no stub matched ${request.method.value} '
'${request.path}. Configure with adapter.when(...).thenReturn(...).',
);
}