Index: sdk/lib/io/http_impl.dart |
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart |
index 787a547143d98f135a144f075bb9a893a3985f7f..5539f3adb92b29bf49eb70840d19d4d080c7c5ef 100644 |
--- a/sdk/lib/io/http_impl.dart |
+++ b/sdk/lib/io/http_impl.dart |
@@ -1487,18 +1487,19 @@ class _HttpClientConnection |
} |
void _onError(e) { |
+ // Cancel any pending data in the HTTP parser. |
+ _httpParser.cancel(); |
if (_socketConn != null) { |
_client._closeSocketConnection(_socketConn); |
} |
- if (_onErrorCallback != null) { |
+ // Report the error. |
+ if (_response != null && _response._streamErrorHandler != null) { |
+ _response._streamErrorHandler(e); |
+ } else if (_onErrorCallback != null) { |
_onErrorCallback(e); |
} else { |
throw e; |
} |
- // Propagate the error to the streams. |
- if (_response != null && _response._streamErrorHandler != null) { |
- _response._streamErrorHandler(e); |
- } |
} |
void _onResponseReceived(int statusCode, |
@@ -1767,8 +1768,8 @@ class _HttpClient implements HttpClient { |
}); |
if (force) { |
_activeSockets.forEach((_SocketConnection socketConn) { |
- socketConn._socket.close(); |
socketConn._httpClientConnection._onClientShutdown(); |
+ socketConn._close(); |
}); |
} |
if (_evictionTimer != null) _cancelEvictionTimer(); |