responseContentLength function

int responseContentLength(
  1. Response? response
)

Gets the size (in bytes) of the response data, using the content-length header, or 0 if unset.

Implementation

int responseContentLength(Response? response) {
  if (response == null) return 0;

  final contentLength = response.headers.value(Headers.contentLengthHeader);
  if (contentLength != null) return _fromContentLength(contentLength);

  return 0;
}