[IO/http] - Fix for https://github.com/dart-lang/sdk/issues/49930
Check for null 'bufferedData' even in the path when 'subscription' is null. Should also fix https://github.com/dart-lang/sdk/issues/26379 TEST=ci Change-Id: Iacc18c8a38e2c5b36c5234495d39cf20bfd8bac3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330201 Reviewed-by: Brian Quinlan <bquinlan@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
@@ -195,9 +195,9 @@ class _HttpDetachedIncoming extends Stream<Uint8List> {
|
||||
return _HttpDetachedStreamSubscription(subscription, bufferedData, onData)
|
||||
..resume();
|
||||
} else {
|
||||
// TODO(26379): add test for this branch.
|
||||
return Stream<Uint8List>.fromIterable([bufferedData!]).listen(onData,
|
||||
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||
return Stream<Uint8List>.fromIterable([bufferedData ?? Uint8List(0)])
|
||||
.listen(onData,
|
||||
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,13 @@
|
||||
|
||||
import "dart:async";
|
||||
import "dart:io";
|
||||
// ignore: IMPORT_INTERNAL_LIBRARY
|
||||
import "dart:_http" show TestingClass$_HttpHeaders, TestingClass$_HttpParser;
|
||||
import "package:async_helper/async_helper.dart";
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
typedef _HttpParser = TestingClass$_HttpParser;
|
||||
|
||||
Future<void> testFormatException() async {
|
||||
final server = await HttpServer.bind("127.0.0.1", 0);
|
||||
server.listen((HttpRequest request) {
|
||||
@@ -28,6 +32,12 @@ Future<void> testFormatException() async {
|
||||
}
|
||||
}
|
||||
|
||||
void testNullSubscriptionData() {
|
||||
_HttpParser httpParser = new _HttpParser.requestParser();
|
||||
httpParser.detachIncoming().listen((data) {}, onDone: () {});
|
||||
}
|
||||
|
||||
main() {
|
||||
asyncTest(testFormatException);
|
||||
testNullSubscriptionData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user