onRequest method
void
onRequest(
- RequestOptions options,
- RequestInterceptorHandler handler, {
- bool skipNext = false,
Called when the request is about to be sent.
Implementation
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler,
{bool skipNext = false}) {
final call = NectorNetworkCall(options.hashCode);
final uri = options.uri;
call.method = options.method;
var path = uri.path;
if (path.isEmpty) path = '/';
call
..endpoint = path
..server = uri.host
..client = 'Dio'
..uri = uri.toString();
final request = NectorNetworkRequest();
final dynamic data = options.data;
if (data == null) {
request
..size = 0
..body = '';
} else {
request
..size = utf8.encode(data.toString()).length
..body = data;
}
request
..time = DateTime.now()
..headers = options.headers
..contentType = options.contentType.toString()
..queryParamters = options.queryParameters;
call
..networkRequest = request
..networkResponse = NectorNetworkResponse();
_controller.addNetworkCall(call);
if (!skipNext) handler.next(options);
}