onRequest method

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

Called when the request is about to be sent.

Implementation

@override
Future onRequest(
    RequestOptions options, RequestInterceptorHandler handler) async {
  final NetworkRequest networkRequest = NetworkRequest();
  networkRequest.startTime = DateTime.now();
  networkRequest.url = options.uri.toString();
  networkRequest.method = options.method;
  networkRequest.requestBody = _parseRequestBody(options);
  networkRequest.requestHeaders = Map<String, String>.from(options.headers);

  _requests[options.hashCode] = networkRequest;

  super.onRequest(options, handler);
}