onRequest method
Called when the request is about to be sent.
Implementation
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
logPrint('***************** Request Start *****************');
_requestMaps[options.uri.toString()] = DateTime.now();
printKV('uri', options.uri);
if (request) {
printKV('method', options.method);
printKV('responseType', options.responseType.toString());
printKV('followRedirects', options.followRedirects);
printKV('connectTimeout', options.connectTimeout?.inMicroseconds??"");
printKV('receiveTimeout', options.receiveTimeout?.inMicroseconds??"");
printKV('extra', options.extra);
}
if (requestHeader) {
logPrint('Request Headers:');
// options.headers.forEach((key, v) => printKV(" $key", v));
printAll(jsonEncode(options.headers));
}
if (requestBody) {
if (options.data is! FormData) {
logPrint("data:");
printAll(jsonEncode(options.data));
}
}
logPrint('***************** Request End *****************');
handlerRequest?.call(options, handler);
super.onRequest(options, handler);
}