onRequest method

  1. @override
void onRequest(
  1. RequestOptions options,
  2. RequestInterceptorHandler handler
)
override

Called when the request is about to be sent.

Implementation

@override
void onRequest(
  RequestOptions options,
  RequestInterceptorHandler handler,
) {
  logPrint('*** Request ***');
  _printKV('uri', options.uri);
  //options.headers;

  if (request) {
    _printKV('method', options.method);
    _printKV('responseType', options.responseType.toString());
    _printKV('followRedirects', options.followRedirects);
    _printKV('persistentConnection', options.persistentConnection);
    _printKV('connectTimeout', options.connectTimeout);
    _printKV('sendTimeout', options.sendTimeout);
    _printKV('receiveTimeout', options.receiveTimeout);
    _printKV(
      'receiveDataWhenStatusError',
      options.receiveDataWhenStatusError,
    );
    _printKV('extra', options.extra);
  }
  if (requestHeader) {
    logPrint('headers:');
    options.headers.forEach((key, v) => _printKV(' $key', v));
  }
  if (requestBody) {
    logPrint('data:');
    _printAll(options.data);
  }
  logPrint('');

  handler.next(options);
}