| Index: runtime/bin/http_parser.dart
|
| diff --git a/runtime/bin/http_parser.dart b/runtime/bin/http_parser.dart
|
| index 074538d441d2ba23d76eebefc44607ddc63bf0a7..92f0f47ee8d390b5b5eb8e773f7dacc688f6a687 100644
|
| --- a/runtime/bin/http_parser.dart
|
| +++ b/runtime/bin/http_parser.dart
|
| @@ -145,6 +145,9 @@ class _HttpParser {
|
| if (_state == _State.UPGRADED) {
|
| throw new HttpParserException("Data on upgraded connection");
|
| }
|
| + if (_state == _State.FAILURE) {
|
| + throw new HttpParserException("Data on failed connection");
|
| + }
|
| while ((index < lastIndex) && _state != _State.FAILURE && _state != _State.UPGRADED) {
|
| int byte = buffer[index];
|
| switch (_state) {
|
| @@ -368,9 +371,10 @@ class _HttpParser {
|
| } else {
|
| String headerField = _headerField.toString();
|
| String headerValue =_headerValue.toString();
|
| - // Ignore the Content-Length header if Transfer-Encoding
|
| - // is chunked (RFC 2616 section 4.4)
|
| + bool reportHeader = true;
|
| if (headerField == "content-length" && !_chunked) {
|
| + // Ignore the Content-Length header if Transfer-Encoding
|
| + // is chunked (RFC 2616 section 4.4)
|
| _contentLength = Math.parseInt(headerValue);
|
| } else if (headerField == "connection") {
|
| List<String> tokens = _tokenizeFieldValue(headerValue);
|
| @@ -383,13 +387,19 @@ class _HttpParser {
|
| } else if (token == "upgrade") {
|
| _connectionUpgrade = true;
|
| }
|
| + if (headerReceived != null) {
|
| + headerReceived(headerField, token);
|
| + }
|
| }
|
| + reportHeader = false;
|
| } else if (headerField == "transfer-encoding" &&
|
| headerValue.toLowerCase() == "chunked") {
|
| + // Ignore the Content-Length header if Transfer-Encoding
|
| + // is chunked (RFC 2616 section 4.4)
|
| _chunked = true;
|
| _contentLength = -1;
|
| }
|
| - if (headerReceived != null) {
|
| + if (reportHeader && headerReceived != null) {
|
| headerReceived(headerField, headerValue);
|
| }
|
| _headerField.clear();
|
|
|