| Index: sdk/lib/io/http_parser.dart
|
| diff --git a/sdk/lib/io/http_parser.dart b/sdk/lib/io/http_parser.dart
|
| index 1d90b144ea33ae7306d063a7381410a8577adc7f..1c9f2982233e5082fd8a9608ad1be6234d92725e 100644
|
| --- a/sdk/lib/io/http_parser.dart
|
| +++ b/sdk/lib/io/http_parser.dart
|
| @@ -450,8 +450,6 @@ class _HttpParser
|
| _state = _State.UPGRADED;
|
| }
|
| _createIncomingConnection();
|
| - _incomingConnection.headers = _headers;
|
| - _incomingConnection.contentLength = _contentLength;
|
| if (_requestParser) {
|
| _incomingConnection.method =
|
| new String.fromCharCodes(_method_or_status_code);
|
| @@ -468,7 +466,7 @@ class _HttpParser
|
| if (_connectionUpgrade) {
|
| _incomingConnection.upgraded = true;
|
| add(_incomingConnection);
|
| - return;
|
| + break;
|
| }
|
| if (_chunked) {
|
| _state = _State.CHUNK_SIZE;
|
| @@ -478,8 +476,7 @@ class _HttpParser
|
| (_noMessageBody || _responseToMethod == "HEAD"))) {
|
| _state = _State.DONE;
|
| add(_incomingConnection);
|
| - _incomingConnection.close();
|
| - _incomingConnection = null;
|
| + _closeIncomingConnection();
|
| break;
|
| } else if (_contentLength > 0) {
|
| _remainingContent = _contentLength;
|
| @@ -536,8 +533,7 @@ class _HttpParser
|
| case _State.CHUNKED_BODY_DONE_LF:
|
| _expect(byte, _CharCode.LF);
|
| _state = _State.DONE;
|
| - _incomingConnection.close();
|
| - _incomingConnection = null;
|
| + _closeIncomingConnection();
|
| break;
|
|
|
| case _State.BODY:
|
| @@ -562,8 +558,7 @@ class _HttpParser
|
| if (_remainingContent == 0) {
|
| if (!_chunked) {
|
| _state = _State.DONE;
|
| - _incomingConnection.close();
|
| - _incomingConnection = null;
|
| + _closeIncomingConnection();
|
| } else {
|
| _state = _State.CHUNK_SIZE_STARTING_CR;
|
| }
|
| @@ -606,14 +601,14 @@ class _HttpParser
|
| // Redirect to _parseObject, if present.
|
| if (_state != _State.DONE &&
|
| _state != _State.UPGRADED &&
|
| + !(_state == _State.START && !_requestParser) &&
|
| !(_state == _State.BODY && !_chunked && _contentLength == -1)) {
|
| _incomingConnection.signalError(
|
| new AsyncError(
|
| new HttpParserException(
|
| "Connection closed while receiving data")));
|
| }
|
| - _incomingConnection.close();
|
| - _incomingConnection = null;
|
| + _closeIncomingConnection();
|
| close();
|
| return;
|
| }
|
| @@ -781,13 +776,24 @@ class _HttpParser
|
|
|
| void _createIncomingConnection() {
|
| assert(_incomingConnection == null);
|
| - _incomingConnection = new _HttpIncomingConnection(_pauseData, _resumeData);
|
| + _incomingConnection = new _HttpIncomingConnection(_headers,
|
| + _pauseData,
|
| + _resumeData);
|
| _incomingConnection.messageHandled.then(() {
|
| - _paused = false;
|
| _reset();
|
| + // Use _resumeData to ensure we start with the current chunk, and not
|
| + // accepting any more, unless we have an empty buffer.
|
| + _resumeData();
|
| });
|
| }
|
|
|
| + void _closeIncomingConnection() {
|
| + assert(_incomingConnection != null);
|
| + var tmp = _incomingConnection;
|
| + _incomingConnection = null;
|
| + tmp.close();
|
| + }
|
| +
|
| void _pauseData() {
|
| if (_pauseCompleter == null) {
|
| _pauseCompleter = new SignalCompleter();
|
| @@ -802,8 +808,10 @@ class _HttpParser
|
| _parse();
|
| if (_paused) return;
|
| }
|
| - _pauseCompleter.complete();
|
| - _pauseCompleter = null;
|
| + if (_pauseCompleter != null) {
|
| + _pauseCompleter.complete();
|
| + _pauseCompleter = null;
|
| + }
|
| }
|
|
|
| void error(error) {
|
|
|