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

Side by Side Diff: sdk/lib/io/http_impl.dart

Issue 1904553006: Fix strong mode errors in dart:io. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Minor changes. Created 4 years, 7 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
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 cancelOnError: cancelOnError); 122 cancelOnError: cancelOnError);
123 } 123 }
124 124
125 Uri get uri => _incoming.uri; 125 Uri get uri => _incoming.uri;
126 126
127 Uri get requestedUri { 127 Uri get requestedUri {
128 if (_requestedUri == null) { 128 if (_requestedUri == null) {
129 var proto = headers['x-forwarded-proto']; 129 var proto = headers['x-forwarded-proto'];
130 var scheme = proto != null ? proto.first : 130 var scheme = proto != null ? proto.first :
131 _httpConnection._socket is SecureSocket ? "https" : "http"; 131 _httpConnection._socket is SecureSocket ? "https" : "http";
132 var host = headers['x-forwarded-host']; 132 var hostList = headers['x-forwarded-host'];
133 if (host != null) { 133 String host;
134 host = host.first; 134 if (hostList != null) {
135 host = hostList.first;
135 } else { 136 } else {
136 host = headers['host']; 137 hostList = headers['host'];
137 if (host != null) { 138 if (hostList != null) {
138 host = host.first; 139 host = hostList.first;
139 } else { 140 } else {
140 host = "${_httpServer.address.host}:${_httpServer.port}"; 141 host = "${_httpServer.address.host}:${_httpServer.port}";
141 } 142 }
142 } 143 }
143 _requestedUri = Uri.parse("$scheme://$host$uri"); 144 _requestedUri = Uri.parse("$scheme://$host$uri");
144 } 145 }
145 return _requestedUri; 146 return _requestedUri;
146 } 147 }
147 148
148 String get method => _incoming.method; 149 String get method => _incoming.method;
(...skipping 26 matching lines...) Expand all
175 class _HttpClientResponse 176 class _HttpClientResponse
176 extends _HttpInboundMessage implements HttpClientResponse { 177 extends _HttpInboundMessage implements HttpClientResponse {
177 List<RedirectInfo> get redirects => _httpRequest._responseRedirects; 178 List<RedirectInfo> get redirects => _httpRequest._responseRedirects;
178 179
179 // The HttpClient this response belongs to. 180 // The HttpClient this response belongs to.
180 final _HttpClient _httpClient; 181 final _HttpClient _httpClient;
181 182
182 // The HttpClientRequest of this response. 183 // The HttpClientRequest of this response.
183 final _HttpClientRequest _httpRequest; 184 final _HttpClientRequest _httpRequest;
184 185
185 List<Cookie> _cookies;
186
187 _HttpClientResponse(_HttpIncoming _incoming, this._httpRequest, 186 _HttpClientResponse(_HttpIncoming _incoming, this._httpRequest,
188 this._httpClient) : super(_incoming) { 187 this._httpClient) : super(_incoming) {
189 // Set uri for potential exceptions. 188 // Set uri for potential exceptions.
190 _incoming.uri = _httpRequest.uri; 189 _incoming.uri = _httpRequest.uri;
191 } 190 }
192 191
193 int get statusCode => _incoming.statusCode; 192 int get statusCode => _incoming.statusCode;
194 String get reasonPhrase => _incoming.reasonPhrase; 193 String get reasonPhrase => _incoming.reasonPhrase;
195 194
196 X509Certificate get certificate { 195 X509Certificate get certificate {
Søren Gjesse 2016/05/04 16:14:09 Maybe add an is-check to throw a better exception?
floitsch 2016/05/04 18:28:41 Done.
197 // The peerCertificate isn't on a plain socket, so cast to dynamic. 196 return (_httpRequest._httpClientConnection._socket as SecureSocket)
198 var socket = _httpRequest._httpClientConnection._socket; 197 .peerCertificate;
199 return socket.peerCertificate;
200 } 198 }
201 199
202 List<Cookie> get cookies { 200 List<Cookie> get cookies {
203 if (_cookies != null) return _cookies; 201 if (_cookies != null) return _cookies;
204 _cookies = new List<Cookie>(); 202 _cookies = new List<Cookie>();
205 List<String> values = headers[HttpHeaders.SET_COOKIE]; 203 List<String> values = headers[HttpHeaders.SET_COOKIE];
206 if (values != null) { 204 if (values != null) {
207 values.forEach((value) { 205 values.forEach((value) {
208 _cookies.add(new Cookie.fromSetCookieValue(value)); 206 _cookies.add(new Cookie.fromSetCookieValue(value));
209 }); 207 });
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 // Used by _HttpOutgoing as a target of a chunked converter for gzip 860 // Used by _HttpOutgoing as a target of a chunked converter for gzip
863 // compression. 861 // compression.
864 class _HttpGZipSink extends ByteConversionSink { 862 class _HttpGZipSink extends ByteConversionSink {
865 final Function _consume; 863 final Function _consume;
866 _HttpGZipSink(this._consume); 864 _HttpGZipSink(this._consume);
867 865
868 void add(List<int> chunk) { 866 void add(List<int> chunk) {
869 _consume(chunk); 867 _consume(chunk);
870 } 868 }
871 869
872 void addSlice(Uint8List chunk, int start, int end, bool isLast) { 870 void addSlice(List<int> chunk, int start, int end, bool isLast) {
873 _consume(new Uint8List.view(chunk.buffer, start, end - start)); 871 if (chunk is Uint8List) {
872 _consume(new Uint8List.view(chunk.buffer, start, end - start));
873 } else {
874 _consume(chunk.sublist(start, end - start));
875 }
874 } 876 }
875 877
876 void close() {} 878 void close() {}
877 } 879 }
878 880
879 881
880 // The _HttpOutgoing handles all of the following: 882 // The _HttpOutgoing handles all of the following:
881 // - Buffering 883 // - Buffering
882 // - GZip compressionm 884 // - GZip compressionm
883 // - Content-Length validation. 885 // - Content-Length validation.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 Future writeHeaders({bool drainRequest: true, bool setOutgoing: true}) { 931 Future writeHeaders({bool drainRequest: true, bool setOutgoing: true}) {
930 Future write() { 932 Future write() {
931 try { 933 try {
932 outbound._writeHeader(); 934 outbound._writeHeader();
933 } catch (_) { 935 } catch (_) {
934 // Headers too large. 936 // Headers too large.
935 return new Future.error(new HttpException( 937 return new Future.error(new HttpException(
936 "Headers size exceeded the of '$_OUTGOING_BUFFER_SIZE'" 938 "Headers size exceeded the of '$_OUTGOING_BUFFER_SIZE'"
937 " bytes")); 939 " bytes"));
938 } 940 }
941 return null;
939 } 942 }
943
940 if (headersWritten) return null; 944 if (headersWritten) return null;
941 headersWritten = true; 945 headersWritten = true;
942 Future drainFuture; 946 Future drainFuture;
943 bool isServerSide = outbound is _HttpResponse;
944 bool gzip = false; 947 bool gzip = false;
945 if (isServerSide) { 948 if (outbound is _HttpResponse) {
946 var response = outbound; 949 // Server side.
950 _HttpResponse response = outbound;
947 if (response._httpRequest._httpServer.autoCompress && 951 if (response._httpRequest._httpServer.autoCompress &&
948 outbound.bufferOutput && 952 outbound.bufferOutput &&
949 outbound.headers.chunkedTransferEncoding) { 953 outbound.headers.chunkedTransferEncoding) {
950 List acceptEncodings = 954 List acceptEncodings =
951 response._httpRequest.headers[HttpHeaders.ACCEPT_ENCODING]; 955 response._httpRequest.headers[HttpHeaders.ACCEPT_ENCODING];
952 List contentEncoding = outbound.headers[HttpHeaders.CONTENT_ENCODING]; 956 List contentEncoding = outbound.headers[HttpHeaders.CONTENT_ENCODING];
953 if (acceptEncodings != null && 957 if (acceptEncodings != null &&
954 acceptEncodings 958 acceptEncodings
955 .expand((list) => list.split(",")) 959 .expand((list) => list.split(","))
956 .any((encoding) => encoding.trim().toLowerCase() == "gzip") && 960 .any((encoding) => encoding.trim().toLowerCase() == "gzip") &&
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 String auth = _CryptoUtils.bytesToBase64( 1492 String auth = _CryptoUtils.bytesToBase64(
1489 UTF8.encode("${proxy.username}:${proxy.password}")); 1493 UTF8.encode("${proxy.username}:${proxy.password}"));
1490 request.headers.set(HttpHeaders.PROXY_AUTHORIZATION, "Basic $auth"); 1494 request.headers.set(HttpHeaders.PROXY_AUTHORIZATION, "Basic $auth");
1491 } 1495 }
1492 return request.close() 1496 return request.close()
1493 .then((response) { 1497 .then((response) {
1494 if (response.statusCode != HttpStatus.OK) { 1498 if (response.statusCode != HttpStatus.OK) {
1495 throw "Proxy failed to establish tunnel " 1499 throw "Proxy failed to establish tunnel "
1496 "(${response.statusCode} ${response.reasonPhrase})"; 1500 "(${response.statusCode} ${response.reasonPhrase})";
1497 } 1501 }
1498 var socket = response._httpRequest._httpClientConnection._socket; 1502 var socket = (response as _HttpClientResponse)._httpRequest
1503 ._httpClientConnection._socket;
1499 return SecureSocket.secure( 1504 return SecureSocket.secure(
1500 socket, 1505 socket,
1501 host: host, 1506 host: host,
1502 context: _context, 1507 context: _context,
1503 onBadCertificate: callback); 1508 onBadCertificate: callback);
1504 }) 1509 })
1505 .then((secureSocket) { 1510 .then((secureSocket) {
1506 String key = _HttpClientConnection.makeKey(true, host, port); 1511 String key = _HttpClientConnection.makeKey(true, host, port);
1507 return new _HttpClientConnection( 1512 return new _HttpClientConnection(
1508 key, secureSocket, request._httpClient, true); 1513 key, secureSocket, request._httpClient, true);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 if (client.maxConnectionsPerHost != null && 1627 if (client.maxConnectionsPerHost != null &&
1623 _active.length + _connecting >= client.maxConnectionsPerHost) { 1628 _active.length + _connecting >= client.maxConnectionsPerHost) {
1624 var completer = new Completer(); 1629 var completer = new Completer();
1625 _pending.add(() { 1630 _pending.add(() {
1626 connect(uriHost, uriPort, proxy, client) 1631 connect(uriHost, uriPort, proxy, client)
1627 .then(completer.complete, onError: completer.completeError); 1632 .then(completer.complete, onError: completer.completeError);
1628 }); 1633 });
1629 return completer.future; 1634 return completer.future;
1630 } 1635 }
1631 var currentBadCertificateCallback = client._badCertificateCallback; 1636 var currentBadCertificateCallback = client._badCertificateCallback;
1632 callback(X509Certificate certificate) => 1637
1633 currentBadCertificateCallback == null ? false : 1638 bool callback(X509Certificate certificate) {
1634 currentBadCertificateCallback(certificate, uriHost, uriPort); 1639 if (currentBadCertificateCallback == null) return false;
1640 return currentBadCertificateCallback(certificate, uriHost, uriPort);
1641 }
1642
1635 Future socketFuture = (isSecure && proxy.isDirect 1643 Future socketFuture = (isSecure && proxy.isDirect
1636 ? SecureSocket.connect(host, 1644 ? SecureSocket.connect(host,
1637 port, 1645 port,
1638 context: context, 1646 context: context,
1639 onBadCertificate: callback) 1647 onBadCertificate: callback)
1640 : Socket.connect(host, port)); 1648 : Socket.connect(host, port));
1641 _connecting++; 1649 _connecting++;
1642 return socketFuture.then((socket) { 1650 return socketFuture.then((socket) {
1643 _connecting--; 1651 _connecting--;
1644 socket.setOption(SocketOption.TCP_NODELAY, true); 1652 socket.setOption(SocketOption.TCP_NODELAY, true);
(...skipping 12 matching lines...) Expand all
1657 return new _ConnectionInfo(connection, proxy); 1665 return new _ConnectionInfo(connection, proxy);
1658 } 1666 }
1659 }, onError: (error) { 1667 }, onError: (error) {
1660 _connecting--; 1668 _connecting--;
1661 _checkPending(); 1669 _checkPending();
1662 throw error; 1670 throw error;
1663 }); 1671 });
1664 } 1672 }
1665 } 1673 }
1666 1674
1675 typedef bool BadCertificateCallback(X509Certificate cr, String host, int port);
1667 1676
1668 class _HttpClient implements HttpClient { 1677 class _HttpClient implements HttpClient {
1669 bool _closing = false; 1678 bool _closing = false;
1670 bool _closingForcefully = false; 1679 bool _closingForcefully = false;
1671 final Map<String, _ConnectionTarget> _connectionTargets 1680 final Map<String, _ConnectionTarget> _connectionTargets
1672 = new HashMap<String, _ConnectionTarget>(); 1681 = new HashMap<String, _ConnectionTarget>();
1673 final List<_Credentials> _credentials = []; 1682 final List<_Credentials> _credentials = [];
1674 final List<_ProxyCredentials> _proxyCredentials = []; 1683 final List<_ProxyCredentials> _proxyCredentials = [];
1675 final SecurityContext _context; 1684 final SecurityContext _context;
1676 Function _authenticate; 1685 Function _authenticate;
1677 Function _authenticateProxy; 1686 Function _authenticateProxy;
1678 Function _findProxy = HttpClient.findProxyFromEnvironment; 1687 Function _findProxy = HttpClient.findProxyFromEnvironment;
1679 Duration _idleTimeout = const Duration(seconds: 15); 1688 Duration _idleTimeout = const Duration(seconds: 15);
1680 Function _badCertificateCallback; 1689 BadCertificateCallback _badCertificateCallback;
1681 1690
1682 Duration get idleTimeout => _idleTimeout; 1691 Duration get idleTimeout => _idleTimeout;
1683 1692
1684 int maxConnectionsPerHost; 1693 int maxConnectionsPerHost;
1685 1694
1686 bool autoUncompress = true; 1695 bool autoUncompress = true;
1687 1696
1688 String userAgent = _getHttpVersion(); 1697 String userAgent = _getHttpVersion();
1689 1698
1690 _HttpClient(SecurityContext this._context); 1699 _HttpClient(SecurityContext this._context);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 String query = null; 1736 String query = null;
1728 if (queryStart < fragmentStart) { 1737 if (queryStart < fragmentStart) {
1729 query = path.substring(queryStart + 1, fragmentStart); 1738 query = path.substring(queryStart + 1, fragmentStart);
1730 path = path.substring(0, queryStart); 1739 path = path.substring(0, queryStart);
1731 } 1740 }
1732 Uri uri = new Uri(scheme: "http", host: host, port: port, 1741 Uri uri = new Uri(scheme: "http", host: host, port: port,
1733 path: path, query: query); 1742 path: path, query: query);
1734 return _openUrl(method, uri); 1743 return _openUrl(method, uri);
1735 } 1744 }
1736 1745
1737 Future<HttpClientRequest> openUrl(String method, Uri url) { 1746 Future<HttpClientRequest> openUrl(String method, Uri url)
1738 return _openUrl(method, url); 1747 => _openUrl(method, url);
1739 }
1740 1748
1741 Future<HttpClientRequest> get(String host, int port, String path) 1749 Future<HttpClientRequest> get(String host, int port, String path)
1742 => open("get", host, port, path); 1750 => open("get", host, port, path);
1743 1751
1744 Future<HttpClientRequest> getUrl(Uri url) => _openUrl("get", url); 1752 Future<HttpClientRequest> getUrl(Uri url) => _openUrl("get", url);
1745 1753
1746 Future<HttpClientRequest> post(String host, int port, String path) 1754 Future<HttpClientRequest> post(String host, int port, String path)
1747 => open("post", host, port, path); 1755 => open("post", host, port, path);
1748 1756
1749 Future<HttpClientRequest> postUrl(Uri url) => _openUrl("post", url); 1757 Future<HttpClientRequest> postUrl(Uri url) => _openUrl("post", url);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 1800
1793 void addProxyCredentials(String host, 1801 void addProxyCredentials(String host,
1794 int port, 1802 int port,
1795 String realm, 1803 String realm,
1796 HttpClientCredentials cr) { 1804 HttpClientCredentials cr) {
1797 _proxyCredentials.add(new _ProxyCredentials(host, port, realm, cr)); 1805 _proxyCredentials.add(new _ProxyCredentials(host, port, realm, cr));
1798 } 1806 }
1799 1807
1800 set findProxy(String f(Uri uri)) => _findProxy = f; 1808 set findProxy(String f(Uri uri)) => _findProxy = f;
1801 1809
1802 Future<HttpClientRequest> _openUrl(String method, Uri uri) { 1810 Future<_HttpClientRequest> _openUrl(String method, Uri uri) {
1803 // Ignore any fragments on the request URI. 1811 // Ignore any fragments on the request URI.
1804 uri = uri.removeFragment(); 1812 uri = uri.removeFragment();
1805 1813
1806 if (method == null) { 1814 if (method == null) {
1807 throw new ArgumentError(method); 1815 throw new ArgumentError(method);
1808 } 1816 }
1809 if (method != "CONNECT") { 1817 if (method != "CONNECT") {
1810 if (uri.host.isEmpty) { 1818 if (uri.host.isEmpty) {
1811 throw new ArgumentError("No host specified in URI $uri"); 1819 throw new ArgumentError("No host specified in URI $uri");
1812 } else if (uri.scheme != "http" && uri.scheme != "https") { 1820 } else if (uri.scheme != "http" && uri.scheme != "https") {
(...skipping 14 matching lines...) Expand all
1827 if (_findProxy != null) { 1835 if (_findProxy != null) {
1828 // TODO(sgjesse): Keep a map of these as normally only a few 1836 // TODO(sgjesse): Keep a map of these as normally only a few
1829 // configuration strings will be used. 1837 // configuration strings will be used.
1830 try { 1838 try {
1831 proxyConf = new _ProxyConfiguration(_findProxy(uri)); 1839 proxyConf = new _ProxyConfiguration(_findProxy(uri));
1832 } catch (error, stackTrace) { 1840 } catch (error, stackTrace) {
1833 return new Future.error(error, stackTrace); 1841 return new Future.error(error, stackTrace);
1834 } 1842 }
1835 } 1843 }
1836 return _getConnection(uri.host, port, proxyConf, isSecure) 1844 return _getConnection(uri.host, port, proxyConf, isSecure)
1837 .then((info) { 1845 .then((_ConnectionInfo info) {
1838 send(info) { 1846
1847 _HttpClientRequest send(_ConnectionInfo info) {
1839 return info.connection.send(uri, 1848 return info.connection.send(uri,
1840 port, 1849 port,
1841 method.toUpperCase(), 1850 method.toUpperCase(),
1842 info.proxy); 1851 info.proxy);
1843 } 1852 }
1853
1844 // If the connection was closed before the request was sent, create 1854 // If the connection was closed before the request was sent, create
1845 // and use another connection. 1855 // and use another connection.
1846 if (info.connection.closed) { 1856 if (info.connection.closed) {
1847 return _getConnection(uri.host, port, proxyConf, isSecure) 1857 return _getConnection(uri.host, port, proxyConf, isSecure)
1848 .then(send); 1858 .then(send);
1849 } 1859 }
1850 return send(info); 1860 return send(info);
1851 }); 1861 });
1852 } 1862 }
1853 1863
1854 Future<HttpClientRequest> _openUrlFromRequest(String method, 1864 Future<_HttpClientRequest> _openUrlFromRequest(String method,
1855 Uri uri, 1865 Uri uri,
1856 _HttpClientRequest previous) { 1866 _HttpClientRequest previous) {
1857 // If the new URI is relative (to either '/' or some sub-path), 1867 // If the new URI is relative (to either '/' or some sub-path),
1858 // construct a full URI from the previous one. 1868 // construct a full URI from the previous one.
1859 Uri resolved = previous.uri.resolveUri(uri); 1869 Uri resolved = previous.uri.resolveUri(uri);
1860 return openUrl(method, resolved).then((_HttpClientRequest request) { 1870 return _openUrl(method, resolved).then((_HttpClientRequest request) {
1861 1871
1862 request 1872 request
1863 // Only follow redirects if initial request did. 1873 // Only follow redirects if initial request did.
1864 ..followRedirects = previous.followRedirects 1874 ..followRedirects = previous.followRedirects
1865 // Allow same number of redirects. 1875 // Allow same number of redirects.
1866 ..maxRedirects = previous.maxRedirects; 1876 ..maxRedirects = previous.maxRedirects;
1867 // Copy headers. 1877 // Copy headers.
1868 for (var header in previous.headers._headers.keys) { 1878 for (var header in previous.headers._headers.keys) {
1869 if (request.headers[header] == null) { 1879 if (request.headers[header] == null) {
1870 request.headers.set(header, previous.headers[header]); 1880 request.headers.set(header, previous.headers[header]);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 // Make sure we go through the event loop before taking a 1944 // Make sure we go through the event loop before taking a
1935 // connection from the pool. For long-running synchronous code the 1945 // connection from the pool. For long-running synchronous code the
1936 // server might have closed the connection, so this lowers the 1946 // server might have closed the connection, so this lowers the
1937 // probability of getting a connection that was already closed. 1947 // probability of getting a connection that was already closed.
1938 return new Future(() => connect(new HttpException("No proxies given"))); 1948 return new Future(() => connect(new HttpException("No proxies given")));
1939 } 1949 }
1940 1950
1941 _SiteCredentials _findCredentials(Uri url, [_AuthenticationScheme scheme]) { 1951 _SiteCredentials _findCredentials(Uri url, [_AuthenticationScheme scheme]) {
1942 // Look for credentials. 1952 // Look for credentials.
1943 _SiteCredentials cr = 1953 _SiteCredentials cr =
1944 _credentials.fold(null, (prev, value) { 1954 _credentials.fold(null, (_SiteCredentials prev, value) {
1945 if (value.applies(url, scheme)) { 1955 var siteCredentials = value as _SiteCredentials;
1956 if (siteCredentials.applies(url, scheme)) {
1946 if (prev == null) return value; 1957 if (prev == null) return value;
1947 return value.uri.path.length > prev.uri.path.length ? value : prev; 1958 return siteCredentials.uri.path.length > prev.uri.path.length
1959 ? siteCredentials
1960 : prev;
1948 } else { 1961 } else {
1949 return prev; 1962 return prev;
1950 } 1963 }
1951 }); 1964 });
1952 return cr; 1965 return cr;
1953 } 1966 }
1954 1967
1955 _ProxyCredentials _findProxyCredentials(_Proxy proxy, 1968 _ProxyCredentials _findProxyCredentials(_Proxy proxy,
1956 [_AuthenticationScheme scheme]) { 1969 [_AuthenticationScheme scheme]) {
1957 // Look for credentials. 1970 // Look for credentials.
1958 var it = _proxyCredentials.iterator; 1971 var it = _proxyCredentials.iterator;
1959 while (it.moveNext()) { 1972 while (it.moveNext()) {
1960 if (it.current.applies(proxy, scheme)) { 1973 if (it.current.applies(proxy, scheme)) {
1961 return it.current; 1974 return it.current;
1962 } 1975 }
1963 } 1976 }
1977 return null;
1964 } 1978 }
1965 1979
1966 void _removeCredentials(_Credentials cr) { 1980 void _removeCredentials(_Credentials cr) {
1967 int index = _credentials.indexOf(cr); 1981 int index = _credentials.indexOf(cr);
1968 if (index != -1) { 1982 if (index != -1) {
1969 _credentials.removeAt(index); 1983 _credentials.removeAt(index);
1970 } 1984 }
1971 } 1985 }
1972 1986
1973 void _removeProxyCredentials(_Credentials cr) { 1987 void _removeProxyCredentials(_Credentials cr) {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 bool get _isIdle => _state == _IDLE; 2173 bool get _isIdle => _state == _IDLE;
2160 bool get _isClosing => _state == _CLOSING; 2174 bool get _isClosing => _state == _CLOSING;
2161 bool get _isDetached => _state == _DETACHED; 2175 bool get _isDetached => _state == _DETACHED;
2162 2176
2163 String get _serviceTypePath => 'io/http/serverconnections'; 2177 String get _serviceTypePath => 'io/http/serverconnections';
2164 String get _serviceTypeName => 'HttpServerConnection'; 2178 String get _serviceTypeName => 'HttpServerConnection';
2165 2179
2166 Map _toJSON(bool ref) { 2180 Map _toJSON(bool ref) {
2167 var name = "${_socket.address.host}:${_socket.port} <-> " 2181 var name = "${_socket.address.host}:${_socket.port} <-> "
2168 "${_socket.remoteAddress.host}:${_socket.remotePort}"; 2182 "${_socket.remoteAddress.host}:${_socket.remotePort}";
2169 var r = { 2183 var r = <String, dynamic>{
2170 'id': _servicePath, 2184 'id': _servicePath,
2171 'type': _serviceType(ref), 2185 'type': _serviceType(ref),
2172 'name': name, 2186 'name': name,
2173 'user_name': name, 2187 'user_name': name,
2174 }; 2188 };
2175 if (ref) { 2189 if (ref) {
2176 return r; 2190 return r;
2177 } 2191 }
2178 r['server'] = _httpServer._toJSON(true); 2192 r['server'] = _httpServer._toJSON(true);
2179 try { 2193 try {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 _idleConnections.forEach((_HttpConnection conn) { 2419 _idleConnections.forEach((_HttpConnection conn) {
2406 result.idle++; 2420 result.idle++;
2407 assert(conn._isIdle); 2421 assert(conn._isIdle);
2408 }); 2422 });
2409 return result; 2423 return result;
2410 } 2424 }
2411 2425
2412 String get _serviceTypePath => 'io/http/servers'; 2426 String get _serviceTypePath => 'io/http/servers';
2413 String get _serviceTypeName => 'HttpServer'; 2427 String get _serviceTypeName => 'HttpServer';
2414 2428
2415 Map _toJSON(bool ref) { 2429 Map<String, dynamic> _toJSON(bool ref) {
2416 var r = { 2430 var r = <String, dynamic>{
2417 'id': _servicePath, 2431 'id': _servicePath,
2418 'type': _serviceType(ref), 2432 'type': _serviceType(ref),
2419 'name': '${address.host}:$port', 2433 'name': '${address.host}:$port',
2420 'user_name': '${address.host}:$port', 2434 'user_name': '${address.host}:$port',
2421 }; 2435 };
2422 if (ref) { 2436 if (ref) {
2423 return r; 2437 return r;
2424 } 2438 }
2425 try { 2439 try {
2426 r['socket'] = _serverSocket._toJSON(true); 2440 r['socket'] = _serverSocket._toJSON(true);
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2866 const _RedirectInfo(this.statusCode, this.method, this.location); 2880 const _RedirectInfo(this.statusCode, this.method, this.location);
2867 } 2881 }
2868 2882
2869 String _getHttpVersion() { 2883 String _getHttpVersion() {
2870 var version = Platform.version; 2884 var version = Platform.version;
2871 // Only include major and minor version numbers. 2885 // Only include major and minor version numbers.
2872 int index = version.indexOf('.', version.indexOf('.') + 1); 2886 int index = version.indexOf('.', version.indexOf('.') + 1);
2873 version = version.substring(0, index); 2887 version = version.substring(0, index);
2874 return 'Dart/$version (dart:io)'; 2888 return 'Dart/$version (dart:io)';
2875 } 2889 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698