length property

int get length

The total length of the request body, in bytes. This is calculated from fields and files and cannot be set manually.

Implementation

int get length {
  int length = 0;
  for (final entry in fields) {
    length += '--'.length +
        _boundary.length +
        _rn.length +
        utf8.encode(_headerForField(entry.key, entry.value)).length +
        utf8.encode(entry.value).length +
        _rn.length;
  }

  for (final file in files) {
    length += '--'.length +
        _boundary.length +
        _rn.length +
        utf8.encode(_headerForFile(file)).length +
        file.value.length +
        _rn.length;
  }

  return length + '--'.length + _boundary.length + '--$_rn'.length;
}