startRequest method

String startRequest(
  1. String method,
  2. String url, {
  3. int? requestBytes,
})

Begins tracking a new HTTP request. Returns a unique id that must be passed to endRequest when the response arrives.

Implementation

String startRequest(
  String method,
  String url, {
  int? requestBytes,
}) {
  if (!enabled) return '';
  final id = '_ri_${_idCounter++}';
  final log = HttpRequestLog(
    id: id,
    method: method.toUpperCase(),
    url: url,
    startTime: DateTime.now(),
    requestBytes: requestBytes,
  );
  _active[id] = log;
  _logs.add(log);
  _trimBuffer();
  _notify();
  return id;
}