contentLength property

  1. @override
int get contentLength
override

The total length of the request body, in bytes.

This is calculated from fields and files and cannot be set manually.

Implementation

@override
int get contentLength {
  var length = 0;

  fields.forEach((name, value) {
    length += '--'.length +
        _boundaryLength +
        '\r\n'.length +
        utf8.encode(_headerForField(name, value)).length +
        utf8.encode(value).length +
        '\r\n'.length;
  });

  for (var file in files) {
    length += '--'.length +
        _boundaryLength +
        '\r\n'.length +
        utf8.encode(_headerForFile(file)).length +
        file.length +
        '\r\n'.length;
  }

  return length + '--'.length + _boundaryLength + '--\r\n'.length;
}
  1. @override
set contentLength (int? value)
override

Implementation

@override
set contentLength(int? value) {
  throw UnsupportedError('Cannot set the contentLength property of '
      'multipart requests.');
}