OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 const int _OUTGOING_BUFFER_SIZE = 8 * 1024; | 7 const int _OUTGOING_BUFFER_SIZE = 8 * 1024; |
8 | 8 |
9 class _HttpIncoming extends Stream<List<int>> { | 9 class _HttpIncoming extends Stream<List<int>> { |
10 final int _transferLength; | 10 final int _transferLength; |
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1542 // TODO(sgjesse): The path set here can contain both query and | 1542 // TODO(sgjesse): The path set here can contain both query and |
1543 // fragment. They should be cracked and set correctly. | 1543 // fragment. They should be cracked and set correctly. |
1544 return _openUrl(method, new Uri( | 1544 return _openUrl(method, new Uri( |
1545 scheme: "http", host: host, port: port, path: path)); | 1545 scheme: "http", host: host, port: port, path: path)); |
1546 } | 1546 } |
1547 | 1547 |
1548 Future<HttpClientRequest> openUrl(String method, Uri url) { | 1548 Future<HttpClientRequest> openUrl(String method, Uri url) { |
1549 return _openUrl(method, url); | 1549 return _openUrl(method, url); |
1550 } | 1550 } |
1551 | 1551 |
1552 Future<HttpClientRequest> get(String host, | 1552 Future<HttpClientRequest> get(String host, int port, String path) |
Søren Gjesse
2014/04/22 08:27:21
We normally only use => when it fits one line.
Lasse Reichstein Nielsen
2014/04/22 08:49:47
I fully accept the two-line case, as long as the b
Anders Johnsen
2014/04/22 10:58:36
Done.
| |
1553 int port, | 1553 => open("get", host, port, path); |
1554 String path) { | |
1555 return open("get", host, port, path); | |
1556 } | |
1557 | 1554 |
1558 Future<HttpClientRequest> getUrl(Uri url) { | 1555 Future<HttpClientRequest> getUrl(Uri url) => _openUrl("get", url); |
1559 return _openUrl("get", url); | |
1560 } | |
1561 | 1556 |
1562 Future<HttpClientRequest> post(String host, | 1557 Future<HttpClientRequest> post(String host, int port, String path) |
1563 int port, | 1558 => open("post", host, port, path); |
Lasse Reichstein Nielsen
2014/04/22 08:49:47
Indent by four.
More below.
Anders Johnsen
2014/04/22 10:58:36
Done.
| |
1564 String path) { | |
1565 return open("post", host, port, path); | |
1566 } | |
1567 | 1559 |
1568 Future<HttpClientRequest> postUrl(Uri url) { | 1560 Future<HttpClientRequest> postUrl(Uri url) => _openUrl("post", url); |
1569 return _openUrl("post", url); | 1561 |
1570 } | 1562 Future<HttpClientRequest> put(String host, int port, String path) |
1563 => open("put", host, port, path); | |
1564 | |
1565 Future<HttpClientRequest> putUrl(Uri url) => _openUrl("put", url); | |
1566 | |
1567 Future<HttpClientRequest> delete(String host, int port, String path) | |
1568 => open("delete", host, port, path); | |
1569 | |
1570 Future<HttpClientRequest> deleteUrl(Uri url) => _openUrl("delete", url); | |
1571 | 1571 |
1572 void close({bool force: false}) { | 1572 void close({bool force: false}) { |
1573 _closing = true; | 1573 _closing = true; |
1574 // Create flattened copy of _idleConnections, as 'destory' will manipulate | 1574 // Create flattened copy of _idleConnections, as 'destory' will manipulate |
1575 // it. | 1575 // it. |
1576 var idle = _idleConnections.values.fold( | 1576 var idle = _idleConnections.values.fold( |
1577 [], | 1577 [], |
1578 (l, e) { | 1578 (l, e) { |
1579 l.addAll(e); | 1579 l.addAll(e); |
1580 return l; | 1580 return l; |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2606 const _RedirectInfo(this.statusCode, this.method, this.location); | 2606 const _RedirectInfo(this.statusCode, this.method, this.location); |
2607 } | 2607 } |
2608 | 2608 |
2609 String _getHttpVersion() { | 2609 String _getHttpVersion() { |
2610 var version = Platform.version; | 2610 var version = Platform.version; |
2611 // Only include major and minor version numbers. | 2611 // Only include major and minor version numbers. |
2612 int index = version.indexOf('.', version.indexOf('.') + 1); | 2612 int index = version.indexOf('.', version.indexOf('.') + 1); |
2613 version = version.substring(0, index); | 2613 version = version.substring(0, index); |
2614 return 'Dart/$version (dart:io)'; | 2614 return 'Dart/$version (dart:io)'; |
2615 } | 2615 } |
OLD | NEW |