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

Side by Side Diff: runtime/bin/http_impl.dart

Issue 11086003: Fix error in in r13348 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class _HttpHeaders implements HttpHeaders { 5 class _HttpHeaders implements HttpHeaders {
6 _HttpHeaders() : _headers = new Map<String, List<String>>(); 6 _HttpHeaders() : _headers = new Map<String, List<String>>();
7 7
8 List<String> operator[](String name) { 8 List<String> operator[](String name) {
9 name = name.toLowerCase(); 9 name = name.toLowerCase();
10 return _headers[name]; 10 return _headers[name];
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 } 2010 }
2011 }); 2011 });
2012 } 2012 }
2013 const _ProxyConfiguration.direct() 2013 const _ProxyConfiguration.direct()
2014 : proxies = [const _Proxy.direct()]; 2014 : proxies = [const _Proxy.direct()];
2015 2015
2016 final List<_Proxy> proxies; 2016 final List<_Proxy> proxies;
2017 } 2017 }
2018 2018
2019 class _Proxy { 2019 class _Proxy {
2020 const _Proxy(this.host, this.port) : direct = false; 2020 const _Proxy(this.host, this.port) : isDirect = false;
2021 const _Proxy.direct() : host = null, port = null, direct = true; 2021 const _Proxy.direct() : host = null, port = null, isDirect = true;
2022 2022
2023 final String host; 2023 final String host;
2024 final int port; 2024 final int port;
2025 final bool direct; 2025 final bool isDirect;
2026 } 2026 }
2027 2027
2028 class _HttpClient implements HttpClient { 2028 class _HttpClient implements HttpClient {
2029 static const int DEFAULT_EVICTION_TIMEOUT = 60000; 2029 static const int DEFAULT_EVICTION_TIMEOUT = 60000;
2030 2030
2031 _HttpClient() : _openSockets = new Map(), 2031 _HttpClient() : _openSockets = new Map(),
2032 _activeSockets = new Set(), 2032 _activeSockets = new Set(),
2033 _shutdown = false; 2033 _shutdown = false;
2034 2034
2035 HttpClientConnection open( 2035 HttpClientConnection open(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 if (_findProxy != null) { 2137 if (_findProxy != null) {
2138 // TODO(sgjesse): Keep a map of these as normally only a few 2138 // TODO(sgjesse): Keep a map of these as normally only a few
2139 // configuration strings will be used. 2139 // configuration strings will be used.
2140 proxyConfiguration = new _ProxyConfiguration(_findProxy(url)); 2140 proxyConfiguration = new _ProxyConfiguration(_findProxy(url));
2141 } 2141 }
2142 2142
2143 // Determine the actual host to connect to. 2143 // Determine the actual host to connect to.
2144 String connectHost; 2144 String connectHost;
2145 int connectPort; 2145 int connectPort;
2146 _Proxy proxy = proxyConfiguration.proxies[0]; 2146 _Proxy proxy = proxyConfiguration.proxies[0];
2147 if (proxy.direct) { 2147 if (proxy.isDirect) {
2148 connectHost = host; 2148 connectHost = host;
2149 connectPort = port; 2149 connectPort = port;
2150 } else { 2150 } else {
2151 connectHost = proxy.host; 2151 connectHost = proxy.host;
2152 connectPort = proxy.port; 2152 connectPort = proxy.port;
2153 } 2153 }
2154 2154
2155 // If there are active connections for this key get the first one 2155 // If there are active connections for this key get the first one
2156 // otherwise create a new one. 2156 // otherwise create a new one.
2157 String key = _connectionKey(connectHost, connectPort); 2157 String key = _connectionKey(connectHost, connectPort);
(...skipping 10 matching lines...) Expand all
2168 }; 2168 };
2169 socket.onConnect = () { 2169 socket.onConnect = () {
2170 // When the connection is established, clear the error 2170 // When the connection is established, clear the error
2171 // callback as it will now be handled by the 2171 // callback as it will now be handled by the
2172 // HttpClientConnection object which will be associated with 2172 // HttpClientConnection object which will be associated with
2173 // the connected socket. 2173 // the connected socket.
2174 socket.onError = null; 2174 socket.onError = null;
2175 _SocketConnection socketConn = 2175 _SocketConnection socketConn =
2176 new _SocketConnection(connectHost, connectPort, socket); 2176 new _SocketConnection(connectHost, connectPort, socket);
2177 _activeSockets.add(socketConn); 2177 _activeSockets.add(socketConn);
2178 _connectionOpened(socketConn, 2178 _connectionOpened(socketConn, connection, !proxy.isDirect);
2179 connection,
2180 !proxyConfiguration.proxies[0].direct);
2181 }; 2179 };
2182 } else { 2180 } else {
2183 _SocketConnection socketConn = socketConnections.removeFirst(); 2181 _SocketConnection socketConn = socketConnections.removeFirst();
2184 _activeSockets.add(socketConn); 2182 _activeSockets.add(socketConn);
2185 new Timer(0, (ignored) => 2183 new Timer(0, (ignored) =>
2186 _connectionOpened(socketConn, 2184 _connectionOpened(socketConn, connection, !proxy.isDirect));
2187 connection,
2188 !proxyConfiguration.proxies[0].direct));
2189 2185
2190 // Get rid of eviction timer if there are no more active connections. 2186 // Get rid of eviction timer if there are no more active connections.
2191 if (socketConnections.isEmpty()) _openSockets.remove(key); 2187 if (socketConnections.isEmpty()) _openSockets.remove(key);
2192 if (_openSockets.isEmpty()) _cancelEvictionTimer(); 2188 if (_openSockets.isEmpty()) _cancelEvictionTimer();
2193 } 2189 }
2194 2190
2195 return connection; 2191 return connection;
2196 } 2192 }
2197 2193
2198 void _returnSocketConnection(_SocketConnection socketConn) { 2194 void _returnSocketConnection(_SocketConnection socketConn) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 2272
2277 2273
2278 class _RedirectInfo implements RedirectInfo { 2274 class _RedirectInfo implements RedirectInfo {
2279 const _RedirectInfo(int this.statusCode, 2275 const _RedirectInfo(int this.statusCode,
2280 String this.method, 2276 String this.method,
2281 Uri this.location); 2277 Uri this.location);
2282 final int statusCode; 2278 final int statusCode;
2283 final String method; 2279 final String method;
2284 final Uri location; 2280 final Uri location;
2285 } 2281 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698