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 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 _closeConnections(_closingForcefully); | 1774 _closeConnections(_closingForcefully); |
1775 assert(!_connectionTargets.values.any((s) => s.hasIdle)); | 1775 assert(!_connectionTargets.values.any((s) => s.hasIdle)); |
1776 assert(!force || | 1776 assert(!force || |
1777 !_connectionTargets.values.any((s) => s._active.isNotEmpty)); | 1777 !_connectionTargets.values.any((s) => s._active.isNotEmpty)); |
1778 } | 1778 } |
1779 | 1779 |
1780 set authenticate(Future<bool> f(Uri url, String scheme, String realm)) { | 1780 set authenticate(Future<bool> f(Uri url, String scheme, String realm)) { |
1781 _authenticate = f; | 1781 _authenticate = f; |
1782 } | 1782 } |
1783 | 1783 |
1784 void addCredentials(Uri url, String realm, HttpClientCredentials cr) => | 1784 void addCredentials(Uri url, String realm, HttpClientCredentials cr) { |
1785 _credentials.add(new _SiteCredentials(url, realm, cr)); | 1785 _credentials.add(new _SiteCredentials(url, realm, cr)); |
| 1786 } |
1786 | 1787 |
1787 set authenticateProxy( | 1788 set authenticateProxy( |
1788 Future<bool> f(String host, int port, String scheme, String realm)) { | 1789 Future<bool> f(String host, int port, String scheme, String realm)) { |
1789 _authenticateProxy = f; | 1790 _authenticateProxy = f; |
1790 } | 1791 } |
1791 | 1792 |
1792 void addProxyCredentials(String host, | 1793 void addProxyCredentials(String host, |
1793 int port, | 1794 int port, |
1794 String realm, | 1795 String realm, |
1795 HttpClientCredentials cr) => | 1796 HttpClientCredentials cr) { |
1796 _proxyCredentials.add(new _ProxyCredentials(host, port, realm, cr)); | 1797 _proxyCredentials.add(new _ProxyCredentials(host, port, realm, cr)); |
| 1798 } |
1797 | 1799 |
1798 set findProxy(String f(Uri uri)) => _findProxy = f; | 1800 set findProxy(String f(Uri uri)) => _findProxy = f; |
1799 | 1801 |
1800 Future<HttpClientRequest> _openUrl(String method, Uri uri) { | 1802 Future<HttpClientRequest> _openUrl(String method, Uri uri) { |
1801 // Ignore any fragments on the request URI. | 1803 // Ignore any fragments on the request URI. |
1802 uri = uri.removeFragment(); | 1804 uri = uri.removeFragment(); |
1803 | 1805 |
1804 if (method == null) { | 1806 if (method == null) { |
1805 throw new ArgumentError(method); | 1807 throw new ArgumentError(method); |
1806 } | 1808 } |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2573 onDone: onDone, | 2575 onDone: onDone, |
2574 cancelOnError: cancelOnError); | 2576 cancelOnError: cancelOnError); |
2575 } | 2577 } |
2576 | 2578 |
2577 Encoding get encoding => _socket.encoding; | 2579 Encoding get encoding => _socket.encoding; |
2578 | 2580 |
2579 void set encoding(Encoding value) { | 2581 void set encoding(Encoding value) { |
2580 _socket.encoding = value; | 2582 _socket.encoding = value; |
2581 } | 2583 } |
2582 | 2584 |
2583 void write(Object obj) => _socket.write(obj); | 2585 void write(Object obj) { _socket.write(obj); } |
2584 | 2586 |
2585 void writeln([Object obj = ""]) => _socket.writeln(obj); | 2587 void writeln([Object obj = ""]) { _socket.writeln(obj); } |
2586 | 2588 |
2587 void writeCharCode(int charCode) => _socket.writeCharCode(charCode); | 2589 void writeCharCode(int charCode) { _socket.writeCharCode(charCode); } |
2588 | 2590 |
2589 void writeAll(Iterable objects, [String separator = ""]) { | 2591 void writeAll(Iterable objects, [String separator = ""]) { |
2590 _socket.writeAll(objects, separator); | 2592 _socket.writeAll(objects, separator); |
2591 } | 2593 } |
2592 | 2594 |
2593 void add(List<int> bytes) => _socket.add(bytes); | 2595 void add(List<int> bytes) { _socket.add(bytes); } |
2594 | 2596 |
2595 void addError(error, [StackTrace stackTrace]) => | 2597 void addError(error, [StackTrace stackTrace]) => |
2596 _socket.addError(error, stackTrace); | 2598 _socket.addError(error, stackTrace); |
2597 | 2599 |
2598 Future<Socket> addStream(Stream<List<int>> stream) { | 2600 Future<Socket> addStream(Stream<List<int>> stream) { |
2599 return _socket.addStream(stream); | 2601 return _socket.addStream(stream); |
2600 } | 2602 } |
2601 | 2603 |
2602 void destroy() => _socket.destroy(); | 2604 void destroy() { _socket.destroy(); } |
2603 | 2605 |
2604 Future flush() => _socket.flush(); | 2606 Future flush() => _socket.flush(); |
2605 | 2607 |
2606 Future close() => _socket.close(); | 2608 Future close() => _socket.close(); |
2607 | 2609 |
2608 Future<Socket> get done => _socket.done; | 2610 Future<Socket> get done => _socket.done; |
2609 | 2611 |
2610 int get port => _socket.port; | 2612 int get port => _socket.port; |
2611 | 2613 |
2612 InternetAddress get address => _socket.address; | 2614 InternetAddress get address => _socket.address; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2761 // 2617. However there is an open draft for adding an additional | 2763 // 2617. However there is an open draft for adding an additional |
2762 // accept-charset parameter to the WWW-Authenticate and | 2764 // accept-charset parameter to the WWW-Authenticate and |
2763 // Proxy-Authenticate headers, see | 2765 // Proxy-Authenticate headers, see |
2764 // http://tools.ietf.org/html/draft-reschke-basicauth-enc-06. For | 2766 // http://tools.ietf.org/html/draft-reschke-basicauth-enc-06. For |
2765 // now always use UTF-8 encoding. | 2767 // now always use UTF-8 encoding. |
2766 String auth = | 2768 String auth = |
2767 _CryptoUtils.bytesToBase64(UTF8.encode("$username:$password")); | 2769 _CryptoUtils.bytesToBase64(UTF8.encode("$username:$password")); |
2768 return "Basic $auth"; | 2770 return "Basic $auth"; |
2769 } | 2771 } |
2770 | 2772 |
2771 void authorize(_Credentials _, HttpClientRequest request) => | 2773 void authorize(_Credentials _, HttpClientRequest request) { |
2772 request.headers.set(HttpHeaders.AUTHORIZATION, authorization()); | 2774 request.headers.set(HttpHeaders.AUTHORIZATION, authorization()); |
| 2775 } |
2773 | 2776 |
2774 void authorizeProxy(_ProxyCredentials _, HttpClientRequest request) => | 2777 void authorizeProxy(_ProxyCredentials _, HttpClientRequest request) { |
2775 request.headers.set(HttpHeaders.PROXY_AUTHORIZATION, authorization()); | 2778 request.headers.set(HttpHeaders.PROXY_AUTHORIZATION, authorization()); |
| 2779 } |
2776 } | 2780 } |
2777 | 2781 |
2778 | 2782 |
2779 class _HttpClientDigestCredentials | 2783 class _HttpClientDigestCredentials |
2780 extends _HttpClientCredentials | 2784 extends _HttpClientCredentials |
2781 implements HttpClientDigestCredentials { | 2785 implements HttpClientDigestCredentials { |
2782 String username; | 2786 String username; |
2783 String password; | 2787 String password; |
2784 | 2788 |
2785 _HttpClientDigestCredentials(this.username, this.password); | 2789 _HttpClientDigestCredentials(this.username, this.password); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2862 const _RedirectInfo(this.statusCode, this.method, this.location); | 2866 const _RedirectInfo(this.statusCode, this.method, this.location); |
2863 } | 2867 } |
2864 | 2868 |
2865 String _getHttpVersion() { | 2869 String _getHttpVersion() { |
2866 var version = Platform.version; | 2870 var version = Platform.version; |
2867 // Only include major and minor version numbers. | 2871 // Only include major and minor version numbers. |
2868 int index = version.indexOf('.', version.indexOf('.') + 1); | 2872 int index = version.indexOf('.', version.indexOf('.') + 1); |
2869 version = version.substring(0, index); | 2873 version = version.substring(0, index); |
2870 return 'Dart/$version (dart:io)'; | 2874 return 'Dart/$version (dart:io)'; |
2871 } | 2875 } |
OLD | NEW |