Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: sdk/lib/io/http_impl.dart

Issue 11879042: Improve the error-propagation on socket streams (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/io/http_parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 08451ab61b03e7fe00b111f86b0c8f8b624203ac..c0d315c68a9bedc4cb4fa4276a4a81a9d4472081 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -751,9 +751,7 @@ abstract class _HttpConnectionBase {
};
_socket.onClosed = _httpParser.streamDone;
_socket.onError = _httpParser.streamError;
- // Ignore errors in the socket output stream as this is getting
- // the same errors as the socket itself.
- _socket.outputStream.onError = (e) => null;
+ _socket.outputStream.onError = _httpParser.streamError;
}
bool _write(List<int> data, [bool copyBuffer = false]);
@@ -876,13 +874,23 @@ class _HttpConnection extends _HttpConnectionBase {
}
void _onError(e) {
- onError(e);
+ // Don't report errors for a request parser when HTTP parser is in
+ // idle state. Clients can close the connection and cause a
+ // connection reset by peer error which is OK.
+ _onClosed();
+ if (_state == _HttpConnectionBase.IDLE) return;
+
// Propagate the error to the streams.
- if (_request != null && _request._streamErrorHandler != null) {
+ if (_request != null &&
+ !_isRequestDone &&
+ _request._streamErrorHandler != null) {
_request._streamErrorHandler(e);
- }
- if (_response != null && _response._streamErrorHandler != null) {
+ } else if (_response != null &&
+ !_isResponseDone &&
+ _response._streamErrorHandler != null) {
_response._streamErrorHandler(e);
+ } else {
+ onError(e);
}
if (_socket != null) _socket.close();
}
« no previous file with comments | « no previous file | sdk/lib/io/http_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698