Skip to content

Commit

Permalink
[IO/http] - Fix for #49930
Browse files Browse the repository at this point in the history
Check for null 'bufferedData' even in the path when 'subscription' is
null. Should also fix #26379

TEST=ci

Change-Id: Iacc18c8a38e2c5b36c5234495d39cf20bfd8bac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330201
Reviewed-by: Brian Quinlan <[email protected]>
Commit-Queue: Siva Annamalai <[email protected]>
  • Loading branch information
a-siva authored and Commit Queue committed Oct 13, 2023
1 parent 5362d95 commit 24155ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sdk/lib/_http/http_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions tests/standalone/io/http_parser_header_add_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -28,6 +32,12 @@ Future<void> testFormatException() async {
}
}

void testNullSubscriptionData() {
_HttpParser httpParser = new _HttpParser.requestParser();
httpParser.detachIncoming().listen((data) {}, onDone: () {});
}

main() {
asyncTest(testFormatException);
testNullSubscriptionData();
}

0 comments on commit 24155ef

Please sign in to comment.