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

Unified Diff: sdk/lib/io/http_impl.dart

Issue 1974043002: Revert "Fix remaining strong-mode warnings and errors in dart:io." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | sdk/lib/io/http_parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 96005c9586f3fdf5e5947ad1144ef0f344a148ce..dff98f04f64c30e13a008bc1de37d282f7082a16 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -6,8 +6,6 @@ part of dart.io;
const int _OUTGOING_BUFFER_SIZE = 8 * 1024;
-typedef void _BytesConsumer(List<int> bytes);
-
class _HttpIncoming extends Stream<List<int>> {
final int _transferLength;
final Completer _dataCompleter = new Completer();
@@ -268,7 +266,7 @@ class _HttpClientResponse
// Since listening to upgraded data is 'bogus', simply close and
// return empty stream subscription.
_httpRequest._httpClientConnection.destroy();
- return new Stream<List<int>>.empty().listen(null, onDone: onDone);
+ return new Stream.fromIterable([]).listen(null, onDone: onDone);
}
var stream = _incoming;
if (_httpClient.autoUncompress &&
@@ -763,16 +761,13 @@ class _HttpClientRequest extends _HttpOutboundMessage<HttpClientResponse>
if (followRedirects && response.isRedirect) {
if (response.redirects.length < maxRedirects) {
// Redirect and drain response.
- future = response.drain()
- .then/*<HttpClientResponse>*/((_) => response.redirect());
+ future = response.drain().then((_) => response.redirect());
} else {
// End with exception, too many redirects.
future = response.drain()
- .then/*<HttpClientResponse>*/((_) {
- return new Future<HttpClientResponse>.error(
- new RedirectException("Redirect limit exceeded",
- response.redirects));
- });
+ .then((_) => new Future.error(
+ new RedirectException("Redirect limit exceeded",
+ response.redirects)));
}
} else if (response._shouldAuthenticateProxy) {
future = response._authenticate(true);
@@ -866,7 +861,7 @@ class _HttpClientRequest extends _HttpOutboundMessage<HttpClientResponse>
// Used by _HttpOutgoing as a target of a chunked converter for gzip
// compression.
class _HttpGZipSink extends ByteConversionSink {
- final _BytesConsumer _consume;
+ final Function _consume;
_HttpGZipSink(this._consume);
void add(List<int> chunk) {
@@ -901,7 +896,7 @@ class _HttpOutgoing implements StreamConsumer<List<int>> {
static const List<int> _chunk0Length =
const [0x30, _CharCode.CR, _CharCode.LF, _CharCode.CR, _CharCode.LF];
- final Completer<Socket> _doneCompleter = new Completer<Socket>();
+ final Completer _doneCompleter = new Completer();
final Socket socket;
bool ignoreBody = false;
@@ -922,7 +917,7 @@ class _HttpOutgoing implements StreamConsumer<List<int>> {
ByteConversionSink _gzipSink;
// _gzipAdd is set iff the sink is being added to. It's used to specify where
// gzipped data should be taken (sometimes a controller, sometimes a socket).
- _BytesConsumer _gzipAdd;
+ Function _gzipAdd;
Uint8List _gzipBuffer;
int _gzipBufferLength = 0;
@@ -1007,16 +1002,16 @@ class _HttpOutgoing implements StreamConsumer<List<int>> {
}
return close();
}
- StreamSubscription<List<int>> sub;
+ var sub;
// Use new stream so we are able to pause (see below listen). The
// alternative is to use stream.extand, but that won't give us a way of
// pausing.
- var controller = new StreamController<List<int>>(
+ var controller = new StreamController(
onPause: () => sub.pause(),
onResume: () => sub.resume(),
sync: true);
- void onData(List<int> data) {
+ void onData(data) {
if (_socketError) return;
if (data.length == 0) return;
if (chunked) {
@@ -1156,7 +1151,7 @@ class _HttpOutgoing implements StreamConsumer<List<int>> {
return _closeFuture = finalize();
}
- Future<Socket> get done => _doneCompleter.future;
+ Future get done => _doneCompleter.future;
void setHeader(List<int> data, int length) {
assert(_length == 0);
@@ -1186,7 +1181,7 @@ class _HttpOutgoing implements StreamConsumer<List<int>> {
=> (error is SocketException || error is TlsException) &&
outbound is HttpResponse;
- void _addGZipChunk(List<int> chunk, void add(List<int> data)) {
+ void _addGZipChunk(chunk, void add(List<int> data)) {
if (!outbound.bufferOutput) {
add(chunk);
return;
@@ -1207,7 +1202,7 @@ class _HttpOutgoing implements StreamConsumer<List<int>> {
}
}
- void _addChunk(List<int> chunk, void add(List<int> data)) {
+ void _addChunk(chunk, void add(List<int> data)) {
if (!outbound.bufferOutput) {
if (_buffer != null) {
// If _buffer is not null, we have not written the header yet. Write
@@ -1276,7 +1271,7 @@ class _HttpClientConnection {
Uri _currentUri;
Completer<_HttpIncoming> _nextResponseCompleter;
- Future<Socket> _streamFuture;
+ Future _streamFuture;
_HttpClientConnection(this.key, this._socket, this._httpClient,
[this._proxyTunnel = false, this._context])
@@ -1391,7 +1386,7 @@ class _HttpClientConnection {
// data).
_httpParser.isHead = method == "HEAD";
_streamFuture = outgoing.done
- .then/*<Socket>*/((Socket s) {
+ .then((s) {
// Request sent, set up response completer.
_nextResponseCompleter = new Completer();
@@ -1486,8 +1481,7 @@ class _HttpClientConnection {
.then((_) => _socket.destroy());
}
- Future<_HttpClientConnection> createProxyTunnel(String host, int port,
- _Proxy proxy, bool callback(X509Certificate certificate)) {
+ Future<_HttpClientConnection> createProxyTunnel(host, port, proxy, callback) {
_HttpClientRequest request =
send(new Uri(host: host, port: port),
port,
@@ -1633,9 +1627,10 @@ class _ConnectionTarget {
}
if (client.maxConnectionsPerHost != null &&
_active.length + _connecting >= client.maxConnectionsPerHost) {
- var completer = new Completer<_ConnectionInfo>();
+ var completer = new Completer();
_pending.add(() {
- completer.complete(connect(uriHost, uriPort, proxy, client));
+ connect(uriHost, uriPort, proxy, client)
+ .then(completer.complete, onError: completer.completeError);
});
return completer.future;
}
@@ -1951,8 +1946,7 @@ class _HttpClient implements HttpClient {
// connection from the pool. For long-running synchronous code the
// server might have closed the connection, so this lowers the
// probability of getting a connection that was already closed.
- return new Future<_ConnectionInfo>(
- () => connect(new HttpException("No proxies given")));
+ return new Future(() => connect(new HttpException("No proxies given")));
}
_SiteCredentials _findCredentials(Uri url, [_AuthenticationScheme scheme]) {
@@ -2080,7 +2074,7 @@ class _HttpConnection
static Map<int, _HttpConnection> _connections =
new HashMap<int, _HttpConnection>();
- final /*_ServerSocket*/ _socket;
+ final _socket;
final _HttpServer _httpServer;
final _HttpParser _httpParser;
int _state = _IDLE;
@@ -2092,7 +2086,7 @@ class _HttpConnection
: _httpParser = new _HttpParser.requestParser() {
try { _socket._owner = this; } catch (_) { print(_); }
_connections[_serviceId] = this;
- _httpParser.listenToStream(_socket as Object/*=Socket*/);
+ _httpParser.listenToStream(_socket);
_subscription = _httpParser.listen(
(incoming) {
_httpServer._markActive(this);
@@ -2468,7 +2462,7 @@ class _HttpServer
// The server listen socket. Untyped as it can be both ServerSocket and
// SecureServerSocket.
- final dynamic/*ServerSocket|SecureServerSocket*/ _serverSocket;
+ final _serverSocket;
final bool _closeServer;
// Set of currently connected clients.
@@ -2583,7 +2577,7 @@ class _HttpConnectionInfo implements HttpConnectionInfo {
class _DetachedSocket extends Stream<List<int>> implements Socket {
final Stream<List<int>> _incoming;
- final Socket _socket;
+ final _socket;
_DetachedSocket(this._socket, this._incoming);
@@ -2618,7 +2612,7 @@ class _DetachedSocket extends Stream<List<int>> implements Socket {
void addError(error, [StackTrace stackTrace]) =>
_socket.addError(error, stackTrace);
- Future addStream(Stream<List<int>> stream) {
+ Future<Socket> addStream(Stream<List<int>> stream) {
return _socket.addStream(stream);
}
@@ -2626,7 +2620,7 @@ class _DetachedSocket extends Stream<List<int>> implements Socket {
Future flush() => _socket.flush();
- Future<Socket> close() => _socket.close();
+ Future close() => _socket.close();
Future<Socket> get done => _socket.done;
@@ -2642,12 +2636,8 @@ class _DetachedSocket extends Stream<List<int>> implements Socket {
return _socket.setOption(option, enabled);
}
- Map _toJSON(bool ref) {
- return (_socket as dynamic)._toJSON(ref);
- }
- void set _owner(owner) {
- (_socket as dynamic)._owner = owner;
- }
+ Map _toJSON(bool ref) => _socket._toJSON(ref);
+ void set _owner(owner) { _socket._owner = owner; }
}
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | sdk/lib/io/http_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698