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

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

Issue 11366169: Fix multiple onRequest callbacks during redirect. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 1 month 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 | tests/standalone/io/http_redirect_test.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 4b8488e8c870964e709a964ffb7f906e38916ab1..3959838e1fc7f2a2737beaabfe4e26a8b27a98da 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -2329,7 +2329,8 @@ class _HttpClient implements HttpClient {
void _establishConnection(String host,
int port,
_ProxyConfiguration proxyConfiguration,
- int proxyIndex) {
+ int proxyIndex,
+ bool reusedConnection) {
void _connectionOpened(_SocketConnection socketConn,
_HttpClientConnection connection,
@@ -2353,7 +2354,9 @@ class _HttpClient implements HttpClient {
cr.authorize(request);
}
}
- if (connection._onRequest != null) {
+ // A reused connection is indicating either redirect or retry
+ // where the onRequest callback should not be issued again.
+ if (connection._onRequest != null && !reusedConnection) {
connection._onRequest(request);
} else {
request.outputStream.close();
@@ -2422,8 +2425,11 @@ class _HttpClient implements HttpClient {
int port = url.port == 0 ? HttpClient.DEFAULT_HTTP_PORT : url.port;
// Create a new connection object if we are not re-using an existing one.
+ var reusedConnection = false;
if (connection == null) {
connection = new _HttpClientConnection(this);
+ } else {
+ reusedConnection = true;
}
connection.onDetach = () => _activeSockets.remove(connection._socketConn);
@@ -2436,7 +2442,7 @@ class _HttpClient implements HttpClient {
}
// Establish the connection starting with the first proxy configured.
- _establishConnection(host, port, proxyConfiguration, 0);
+ _establishConnection(host, port, proxyConfiguration, 0, reusedConnection);
return connection;
}
« no previous file with comments | « no previous file | tests/standalone/io/http_redirect_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698