Revert recent changes to File.openRead() and HttpClientResponse APIs

This changes `File.openRead()` back to returning a `Stream<List<int>>`
and `HttpClientResponse` back to implementing `Stream<List<int>>`.
These two changes broke a significant number of call sites; backing it
out enables us to keep the changes from landing in the next dev release
until we analyze whether we can roll these changes out in a softer
manner or if they're worth making at all.

Bug: https://github.com/dart-lang/sdk/issues/36900
Change-Id: I8977abcba40c58a4ca2b4a05d857512989a1e0b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109102
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Todd Volkert <tvolkert@google.com>
This commit is contained in:
Todd Volkert 2019-07-16 06:05:11 +00:00 committed by commit-bot@chromium.org
parent 4cd16d3954
commit 1c4ad14fa3
5 changed files with 24 additions and 9 deletions

View file

@ -22,12 +22,10 @@
* `RawSocket.read()`
* `Utf8Codec.encode()` (and `Utf8Encoder.convert()`)
In addition, the following methods and classes were updated to return or
implement `Stream<Uint8List>` rather than `Stream<List<int>>`:
In addition, the following classes were updated to implement
`Stream<Uint8List>` rather than `Stream<List<int>>`:
* `File.openRead()`
* `HttpRequest`
* `HttpClientResponse`
* `Socket`
**Possible errors and how to fix them**

View file

@ -1947,7 +1947,7 @@ abstract class HttpClientRequest implements IOSink {
* });
* });
*/
abstract class HttpClientResponse implements Stream<Uint8List> {
abstract class HttpClientResponse implements Stream<List<int>> {
/**
* Returns the status code.
*

View file

@ -173,6 +173,23 @@ class _HttpIncoming extends Stream<Uint8List> {
}
}
abstract class _HttpInboundMessageListInt extends Stream<List<int>> {
final _HttpIncoming _incoming;
List<Cookie> _cookies;
_HttpInboundMessageListInt(this._incoming);
List<Cookie> get cookies {
if (_cookies != null) return _cookies;
return _cookies = headers._parseCookies();
}
_HttpHeaders get headers => _incoming.headers;
String get protocolVersion => headers.protocolVersion;
int get contentLength => headers.contentLength;
bool get persistentConnection => headers.persistentConnection;
}
abstract class _HttpInboundMessage extends Stream<Uint8List> {
final _HttpIncoming _incoming;
List<Cookie> _cookies;
@ -282,7 +299,7 @@ class _HttpRequest extends _HttpInboundMessage implements HttpRequest {
}
}
class _HttpClientResponse extends _HttpInboundMessage
class _HttpClientResponse extends _HttpInboundMessageListInt
implements HttpClientResponse {
List<RedirectInfo> get redirects => _httpRequest._responseRedirects;

View file

@ -483,7 +483,7 @@ abstract class File implements FileSystemEntity {
* must be read to completion or the subscription on the stream must
* be cancelled.
*/
Stream<Uint8List> openRead([int start, int end]);
Stream<List<int>> openRead([int start, int end]);
/**
* Creates a new independent [IOSink] for the file. The

View file

@ -7,7 +7,7 @@ part of dart.io;
// Read the file in blocks of size 64k.
const int _blockSize = 64 * 1024;
class _FileStream extends Stream<Uint8List> {
class _FileStream extends Stream<List<int>> {
// Stream controller.
StreamController<Uint8List> _controller;
@ -498,7 +498,7 @@ class _File extends FileSystemEntity implements File {
return new _RandomAccessFile(id, "");
}
Stream<Uint8List> openRead([int start, int end]) {
Stream<List<int>> openRead([int start, int end]) {
return new _FileStream(path, start, end);
}