onRequest method
Called when the request is about to be sent.
Implementation
@override
Future<void> onRequest(
RequestOptions options, RequestInterceptorHandler handler) async {
var intermediate = options;
for (final interceptor in _interceptors) {
try {
final dynamic res = await interceptor.onRequest(intermediate);
if (res is RequestOptions) {
intermediate = res;
continue;
} else if (res is DioException) {
handler.reject(res, false);
return;
}
} on DioException catch (e) {
handler.reject(e, false);
return;
} catch (e) {
handler.reject(DioException(requestOptions: options, error: e));
return;
}
}
handler.next(intermediate);
}