Fix a bug where the HttpClient response stream was cancelled after completed (#1792) * Fix a bug where the HttpClient response stream was cancelled after completed * Update version to 1.5.0-beta.2
diff --git a/pkgs/http/CHANGELOG.md b/pkgs/http/CHANGELOG.md index d29dfc2..80d9110 100644 --- a/pkgs/http/CHANGELOG.md +++ b/pkgs/http/CHANGELOG.md
@@ -1,3 +1,8 @@ +## 1.5.0-beta.2 + +* Fixed a bug in `IOClient` where the `HttpClient`'s response stream was + cancelled after the response stream was completed. + ## 1.5.0-beta * Added support for aborting requests before they complete.
diff --git a/pkgs/http/lib/src/io_client.dart b/pkgs/http/lib/src/io_client.dart index 7d64af2..f259181 100644 --- a/pkgs/http/lib/src/io_client.dart +++ b/pkgs/http/lib/src/io_client.dart
@@ -175,7 +175,13 @@ ioResponseSubscription = response.listen( responseController.add, - onDone: responseController.close, + onDone: () { + // `reponseController.close` will trigger the `onCancel` callback. + // Assign `ioResponseSubscription` to `null` to avoid calling its + // `cancel` method. + ioResponseSubscription = null; + unawaited(responseController.close()); + }, onError: (Object err, StackTrace stackTrace) { if (err is HttpException) { responseController.addError(
diff --git a/pkgs/http/pubspec.yaml b/pkgs/http/pubspec.yaml index e243e5f..442b6b9 100644 --- a/pkgs/http/pubspec.yaml +++ b/pkgs/http/pubspec.yaml
@@ -1,5 +1,5 @@ name: http -version: 1.5.0-beta +version: 1.5.0-beta.2 description: A composable, multi-platform, Future-based API for HTTP requests. repository: https://github.com/dart-lang/http/tree/master/pkgs/http