Chromium Code Reviews| 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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1255 | 1255 |
| 1256 DetachedSocket detachSocket() { | 1256 DetachedSocket detachSocket() { |
| 1257 return _detachSocket(); | 1257 return _detachSocket(); |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 void _onConnectionClosed(e) { | 1260 void _onConnectionClosed(e) { |
| 1261 // Socket is closed either due to an error or due to normal socket close. | 1261 // Socket is closed either due to an error or due to normal socket close. |
| 1262 if (e != null) { | 1262 if (e != null) { |
| 1263 if (_onErrorCallback != null) { | 1263 if (_onErrorCallback != null) { |
| 1264 _onErrorCallback(e); | 1264 _onErrorCallback(e); |
| 1265 } else { | |
| 1266 throw e; | |
| 1265 } | 1267 } |
| 1266 } | 1268 } |
| 1267 _closing = true; | 1269 _closing = true; |
| 1268 if (e != null) { | 1270 if (e != null) { |
| 1269 // Propagate the error to the streams. | 1271 // Propagate the error to the streams. |
| 1270 if (_response != null && _response._streamErrorHandler != null) { | 1272 if (_response != null && _response._streamErrorHandler != null) { |
| 1271 _response._streamErrorHandler(e); | 1273 _response._streamErrorHandler(e); |
| 1272 } | 1274 } |
| 1273 _responseDone(); | 1275 _responseDone(); |
| 1274 } else { | 1276 } else { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1359 class _HttpClient implements HttpClient { | 1361 class _HttpClient implements HttpClient { |
| 1360 static final int DEFAULT_EVICTION_TIMEOUT = 60000; | 1362 static final int DEFAULT_EVICTION_TIMEOUT = 60000; |
| 1361 | 1363 |
| 1362 _HttpClient() : _openSockets = new Map(), | 1364 _HttpClient() : _openSockets = new Map(), |
| 1363 _activeSockets = new Set(), | 1365 _activeSockets = new Set(), |
| 1364 _shutdown = false; | 1366 _shutdown = false; |
| 1365 | 1367 |
| 1366 HttpClientConnection open( | 1368 HttpClientConnection open( |
| 1367 String method, String host, int port, String path) { | 1369 String method, String host, int port, String path) { |
| 1368 if (_shutdown) throw new HttpException("HttpClient shutdown"); | 1370 if (_shutdown) throw new HttpException("HttpClient shutdown"); |
| 1371 if (method == null || host == null || port == null || path == null) { | |
| 1372 throw new NullPointerException(); | |
|
Mads Ager (google)
2012/05/03 13:36:28
We could throw a more descriptive error here? Not
Søren Gjesse
2012/05/07 11:42:31
Changed to IllegalArgumentException.
Arguments ar
| |
| 1373 } | |
| 1369 return _prepareHttpClientConnection(host, port, method, path); | 1374 return _prepareHttpClientConnection(host, port, method, path); |
| 1370 } | 1375 } |
| 1371 | 1376 |
| 1372 HttpClientConnection openUrl(String method, Uri url) { | 1377 HttpClientConnection openUrl(String method, Uri url) { |
| 1373 if (url.scheme != "http") { | 1378 if (url.scheme != "http") { |
| 1374 throw new HttpException("Unsupported URL scheme ${url.scheme}"); | 1379 throw new HttpException("Unsupported URL scheme ${url.scheme}"); |
| 1375 } | 1380 } |
| 1376 if (url.userInfo != "") { | 1381 if (url.userInfo != "") { |
| 1377 throw new HttpException("Unsupported user info ${url.userInfo}"); | 1382 throw new HttpException("Unsupported user info ${url.userInfo}"); |
| 1378 } | 1383 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1534 } | 1539 } |
| 1535 | 1540 |
| 1536 | 1541 |
| 1537 class _DetachedSocket implements DetachedSocket { | 1542 class _DetachedSocket implements DetachedSocket { |
| 1538 _DetachedSocket(this._socket, this._unparsedData); | 1543 _DetachedSocket(this._socket, this._unparsedData); |
| 1539 Socket get socket() => _socket; | 1544 Socket get socket() => _socket; |
| 1540 List<int> get unparsedData() => _unparsedData; | 1545 List<int> get unparsedData() => _unparsedData; |
| 1541 Socket _socket; | 1546 Socket _socket; |
| 1542 List<int> _unparsedData; | 1547 List<int> _unparsedData; |
| 1543 } | 1548 } |
| OLD | NEW |