diff --git a/dio/CHANGELOG.md b/dio/CHANGELOG.md index 4a43995d3..4243c1626 100644 --- a/dio/CHANGELOG.md +++ b/dio/CHANGELOG.md @@ -7,6 +7,7 @@ See the [Migration Guide][] for the complete breaking changes list.** - Update comments and strings with `MultipartFile`. - Removes redundant warnings when composing request options on Web. +- Fixes boundary inconsistency in `FormData.clone()`. ## 5.7.0 diff --git a/dio/lib/src/form_data.dart b/dio/lib/src/form_data.dart index 10bc5f626..2fc4cd548 100644 --- a/dio/lib/src/form_data.dart +++ b/dio/lib/src/form_data.dart @@ -74,7 +74,7 @@ class FormData { /// /// See also: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html String get boundary => _boundary; - late final String _boundary; + late String _boundary; /// The form fields to send for this request. final fields = >[]; @@ -210,6 +210,7 @@ class FormData { // Convenience method to clone finalized FormData when retrying requests. FormData clone() { final clone = FormData(); + clone._boundary = _boundary; clone.fields.addAll(fields); for (final file in files) { clone.files.add(MapEntry(file.key, file.value.clone())); diff --git a/dio/test/formdata_test.dart b/dio/test/formdata_test.dart index 109a53246..ee299ecdf 100644 --- a/dio/test/formdata_test.dart +++ b/dio/test/formdata_test.dart @@ -176,6 +176,7 @@ void main() async { expect(fm1 != fm, true); expect(fm1.files[0].value.filename, fm.files[0].value.filename); expect(fm1.fields, fm.fields); + expect(fm1.boundary, fm.boundary); }, testOn: 'vm', ); diff --git a/dio_test/lib/src/test/basic_tests.dart b/dio_test/lib/src/test/basic_tests.dart index c6e589e1d..363f31a46 100644 --- a/dio_test/lib/src/test/basic_tests.dart +++ b/dio_test/lib/src/test/basic_tests.dart @@ -17,7 +17,7 @@ void basicTests( group('basic request', () { test( 'works with non-TLS requests', - () => dio.get('http://neverssl.com/'), + () => dio.get('http://flutter-io.cn/'), testOn: 'vm', );