| OLD | NEW |
| 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 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 if (socketConnections.isEmpty()) { | 1340 if (socketConnections.isEmpty()) { |
| 1341 _evictionTimer.cancel(); | 1341 _evictionTimer.cancel(); |
| 1342 _evictionTimer = null; | 1342 _evictionTimer = null; |
| 1343 } | 1343 } |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 return connection; | 1346 return connection; |
| 1347 } | 1347 } |
| 1348 | 1348 |
| 1349 void _returnSocketConnection(_SocketConnection socketConn) { | 1349 void _returnSocketConnection(_SocketConnection socketConn) { |
| 1350 // Mark socket as returned to unregister from the old connection. |
| 1351 socketConn._markReturned(); |
| 1352 |
| 1350 // If the HTTP client is beeing shutdown don't return the connection. | 1353 // If the HTTP client is beeing shutdown don't return the connection. |
| 1351 if (_shutdown) { | 1354 if (_shutdown) { |
| 1352 socketConn._socket.close(); | 1355 socketConn._socket.close(); |
| 1353 return; | 1356 return; |
| 1354 }; | 1357 }; |
| 1355 | 1358 |
| 1356 String key = _connectionKey(socketConn._host, socketConn._port); | 1359 String key = _connectionKey(socketConn._host, socketConn._port); |
| 1357 | 1360 |
| 1358 // Get or create the connection list for this key. | 1361 // Get or create the connection list for this key. |
| 1359 Queue sockets = _openSockets[key]; | 1362 Queue sockets = _openSockets[key]; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1381 } | 1384 } |
| 1382 } | 1385 } |
| 1383 }); | 1386 }); |
| 1384 } | 1387 } |
| 1385 _evictionTimer = new Timer.repeating(10000, _handleEviction); | 1388 _evictionTimer = new Timer.repeating(10000, _handleEviction); |
| 1386 } | 1389 } |
| 1387 | 1390 |
| 1388 // Return connection. | 1391 // Return connection. |
| 1389 _activeSockets.remove(socketConn); | 1392 _activeSockets.remove(socketConn); |
| 1390 sockets.addFirst(socketConn); | 1393 sockets.addFirst(socketConn); |
| 1391 socketConn._markReturned(); | |
| 1392 } | 1394 } |
| 1393 | 1395 |
| 1394 Function _onOpen; | 1396 Function _onOpen; |
| 1395 Map<String, Queue<_SocketConnection>> _openSockets; | 1397 Map<String, Queue<_SocketConnection>> _openSockets; |
| 1396 Set<_SocketConnection> _activeSockets; | 1398 Set<_SocketConnection> _activeSockets; |
| 1397 Timer _evictionTimer; | 1399 Timer _evictionTimer; |
| 1398 bool _shutdown; // Has this HTTP client been shutdown? | 1400 bool _shutdown; // Has this HTTP client been shutdown? |
| 1399 } | 1401 } |
| OLD | NEW |