contentLength property
The value of the contentLengthHeader header, if any.
The value is negative if there is no content length set.
Implementation
@override
int get contentLength => _contentLength;
The value of the contentLengthHeader header, if any.
The value is negative if there is no content length set.
Implementation
@override
set contentLength(int contentLength) {
_checkMutable();
if (protocolVersion == "1.0" &&
persistentConnection &&
contentLength == -1) {
throw HttpException(
"Trying to clear ContentLength on HTTP 1.0 headers with "
"'Connection: Keep-Alive' set");
}
if (_contentLength == contentLength) return;
_contentLength = contentLength;
if (_contentLength >= 0) {
if (chunkedTransferEncoding) chunkedTransferEncoding = false;
_set(HttpHeaders.contentLengthHeader, contentLength.toString());
} else {
_headers.remove(HttpHeaders.contentLengthHeader);
if (protocolVersion == "1.1") {
chunkedTransferEncoding = true;
}
}
}