onRequest method
Called when the request is about to be sent.
Implementation
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
if (kReleaseMode) return super.onRequest(options, handler);
options.extra['_requestStartTime'] = DateTime.now();
final requestLog =
StringBuffer('HTTP Request: ${options.method} ${options.uri}');
if (logRequestHeaders) {
final headers = _redactHeaders(options.headers);
requestLog.write('\nHeaders: $headers');
}
if (logRequestBody && options.data != null) {
requestLog.write('\nBody: ${_formatBody(options.data)}');
}
logger.info(requestLog.toString(), tag: 'HTTP');
super.onRequest(options, handler);
}