diff --git a/pkgs/http_profile/lib/src/http_profile_request_data.dart b/pkgs/http_profile/lib/src/http_profile_request_data.dart index 537643cc2c..60b1d8e8fe 100644 --- a/pkgs/http_profile/lib/src/http_profile_request_data.dart +++ b/pkgs/http_profile/lib/src/http_profile_request_data.dart @@ -55,6 +55,9 @@ final class HttpProfileRequestData { _data['requestData'] as Map; /// A sink that can be used to record the body of the request. + /// + /// Errors added to [bodySink] (for example with [StreamSink.addError]) are + /// ignored. StreamSink> get bodySink => _body.sink; /// The body of the request represented as an unmodifiable list of bytes. diff --git a/pkgs/http_profile/lib/src/http_profile_response_data.dart b/pkgs/http_profile/lib/src/http_profile_response_data.dart index 8cf0f682d6..920b97d601 100644 --- a/pkgs/http_profile/lib/src/http_profile_response_data.dart +++ b/pkgs/http_profile/lib/src/http_profile_response_data.dart @@ -62,6 +62,9 @@ final class HttpProfileResponseData { .map(HttpProfileRedirectData._fromJson)); /// A sink that can be used to record the body of the response. + /// + /// Errors added to [bodySink] (for example with [StreamSink.addError]) are + /// ignored. StreamSink> get bodySink => _body.sink; /// The body of the response represented as an unmodifiable list of bytes. diff --git a/pkgs/http_profile/test/http_profile_request_data_test.dart b/pkgs/http_profile/test/http_profile_request_data_test.dart index 36c79a766f..500cd95f52 100644 --- a/pkgs/http_profile/test/http_profile_request_data_test.dart +++ b/pkgs/http_profile/test/http_profile_request_data_test.dart @@ -348,9 +348,11 @@ void main() { expect(profile.requestData.bodyBytes, isEmpty); profile.requestData.bodySink.add([1, 2, 3]); + profile.requestData.bodySink.addError('this is an error'); + profile.requestData.bodySink.add([4, 5]); await profile.requestData.close(); - expect(requestBodyBytes, [1, 2, 3]); - expect(profile.requestData.bodyBytes, [1, 2, 3]); + expect(requestBodyBytes, [1, 2, 3, 4, 5]); + expect(profile.requestData.bodyBytes, [1, 2, 3, 4, 5]); }); } diff --git a/pkgs/http_profile/test/http_profile_response_data_test.dart b/pkgs/http_profile/test/http_profile_response_data_test.dart index 9b73cb7b38..a9bc9a827c 100644 --- a/pkgs/http_profile/test/http_profile_response_data_test.dart +++ b/pkgs/http_profile/test/http_profile_response_data_test.dart @@ -392,9 +392,11 @@ void main() { expect(profile.responseData.bodyBytes, isEmpty); profile.responseData.bodySink.add([1, 2, 3]); + profile.responseData.bodySink.addError('this is an error'); + profile.responseData.bodySink.add([4, 5]); await profile.responseData.close(); - expect(responseBodyBytes, [1, 2, 3]); - expect(profile.responseData.bodyBytes, [1, 2, 3]); + expect(responseBodyBytes, [1, 2, 3, 4, 5]); + expect(profile.responseData.bodyBytes, [1, 2, 3, 4, 5]); }); }