in lib/src/http_parser.dart [284:343]
bool _headersEnd() {
_headers.mutable = false;
_transferLength = _headers.contentLength;
// Ignore the Content-Length header if Transfer-Encoding
// is chunked (RFC 2616 section 4.4)
if (_chunked) _transferLength = -1;
// If a request message has neither Content-Length nor
// Transfer-Encoding the message must not have a body (RFC
// 2616 section 4.3).
if (_messageType == _MessageType.REQUEST &&
_transferLength < 0 &&
_chunked == false) {
_transferLength = 0;
}
if (_connectionUpgrade) {
_state = _State.UPGRADED;
_transferLength = 0;
}
_createIncoming(_transferLength);
if (_requestParser) {
_incoming.method = String.fromCharCodes(_method);
_incoming.uri = Uri.parse(String.fromCharCodes(_uri_or_reason_phrase));
} else {
_incoming.statusCode = _statusCode;
_incoming.reasonPhrase = String.fromCharCodes(_uri_or_reason_phrase);
}
_method.clear();
_uri_or_reason_phrase.clear();
if (_connectionUpgrade) {
_incoming.upgraded = true;
_parserCalled = false;
var tmp = _incoming;
_closeIncoming();
_controller.add(tmp);
return true;
}
if (_transferLength == 0 ||
(_messageType == _MessageType.RESPONSE && _noMessageBody)) {
_reset();
var tmp = _incoming;
_closeIncoming();
_controller.add(tmp);
return false;
} else if (_chunked) {
_state = _State.CHUNK_SIZE;
_remainingContent = 0;
} else if (_transferLength > 0) {
_remainingContent = _transferLength;
_state = _State.BODY;
} else {
// Neither chunked nor content length. End of body
// indicated by close.
_state = _State.BODY;
}
_parserCalled = false;
_controller.add(_incoming);
return true;
}