onRequest method

void onRequest(
  1. HttpClientRequest request, {
  2. dynamic requestBody,
})

Implementation

void onRequest(HttpClientRequest request, {dynamic requestBody}) {
  final requestHeaders = <String, dynamic>{};
  request.headers.forEach((String header, dynamic value) {
    requestHeaders[header] = value[0];
  });
  final NetworkData requestData = NetworkData(
    startTime: DateTime.now(),
    method: request.method,
    url: request.uri.toString(),
    requestHeaders: requestHeaders,
    requestBody: requestBody ?? '',
    requestBodySize: int.parse(requestHeaders['content-length'] ?? '0'),
  );

  requests[request.hashCode] = requestData;
}