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

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

Issue 15256002: Rewrite parts of http-parser, to better handle connection errors and pausing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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') | sdk/lib/io/http_parser.dart » ('J')
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 9d6456f82076389b0905bf22f1b2abf8351df328..d95fb5b76a3a015e44d4c4c666ffc5b0512676c3 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -1071,6 +1071,7 @@ class _HttpClientConnection {
StreamSubscription _subscription;
final _HttpClient _httpClient;
bool _dispose = false;
+ bool closed = false;
Søren Gjesse 2013/05/17 07:09:28 Private? (also key above).
Anders Johnsen 2013/05/17 08:27:59 This is used from another class (HttpClient). Also
Completer<_HttpIncoming> _nextResponseCompleter;
Future _streamFuture;
@@ -1102,11 +1103,19 @@ class _HttpClientConnection {
}
},
onDone: () {
+ if (_nextResponseCompleter != null) {
+ _nextResponseCompleter.completeError(new HttpException(
+ "Connection closed before response was received"));
+ _nextResponseCompleter = null;
+ }
close();
});
}
_HttpClientRequest send(Uri uri, int port, String method, _Proxy proxy) {
+ if (closed) {
+ throw new HttpException("Socket closed before request was sent");
+ }
// Start with pausing the parser.
_subscription.pause();
_ProxyCredentials proxyCreds; // Credentials used to authorize proxy.
@@ -1227,11 +1236,13 @@ class _HttpClientConnection {
}
void destroy() {
+ closed = true;
_httpClient._connectionClosed(this);
_socket.destroy();
}
void close() {
+ closed = true;
_httpClient._connectionClosed(this);
_streamFuture
// TODO(ajohnsen): Add timeout.
@@ -1407,10 +1418,19 @@ class _HttpClient implements HttpClient {
}
return _getConnection(uri.domain, port, proxyConf, isSecure)
.then((info) {
- return info.connection.send(uri,
- port,
- method.toUpperCase(),
- info.proxy);
+ send(info) {
+ return info.connection.send(uri,
+ port,
+ method.toUpperCase(),
+ info.proxy);
+ }
+ // If the connection was closed before the request was sent, create
+ // and use another connection.
+ if (info.connection.closed) {
+ return _getConnection(uri.domain, port, proxyConf, isSecure)
+ .then(send);
+ }
+ return send(info);
});
}
« no previous file with comments | « no previous file | sdk/lib/io/http_parser.dart » ('j') | sdk/lib/io/http_parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698