From 0786c063354cae49333551c4d32795593d2756d7 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Mon, 7 Oct 2024 10:21:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=A5=20Remove=20redundant=20warning?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dio/lib/src/options.dart | 14 -------------- plugins/web_adapter/lib/src/adapter.dart | 9 +++++---- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/dio/lib/src/options.dart b/dio/lib/src/options.dart index c836798b0..1f1e58983 100644 --- a/dio/lib/src/options.dart +++ b/dio/lib/src/options.dart @@ -309,20 +309,6 @@ class Options { ProgressCallback? onReceiveProgress, StackTrace? sourceStackTrace, }) { - if (data != null && kIsWeb) { - if (sendTimeout != null && sendTimeout! > Duration.zero) { - warningLog( - 'sendTimeout cannot be used without a request body to send on Web', - StackTrace.current, - ); - } - if (onSendProgress != null) { - warningLog( - 'onSendProgress cannot be used without a request body to send on Web', - StackTrace.current, - ); - } - } final query = {}; query.addAll(baseOpt.queryParameters); if (queryParameters != null) { diff --git a/plugins/web_adapter/lib/src/adapter.dart b/plugins/web_adapter/lib/src/adapter.dart index cec2d2c47..df43ed629 100644 --- a/plugins/web_adapter/lib/src/adapter.dart +++ b/plugins/web_adapter/lib/src/adapter.dart @@ -55,9 +55,11 @@ class BrowserHttpClientAdapter implements HttpClientAdapter { } }); + final onSendProgress = options.onSendProgress; final sendTimeout = options.sendTimeout ?? Duration.zero; final connectTimeout = options.connectTimeout ?? Duration.zero; final receiveTimeout = options.receiveTimeout ?? Duration.zero; + final xhrTimeout = (connectTimeout + receiveTimeout).inMilliseconds; xhr.timeout = xhrTimeout; @@ -138,7 +140,6 @@ class BrowserHttpClientAdapter implements HttpClientAdapter { }); } - final onSendProgress = options.onSendProgress; if (onSendProgress != null) { xhrUploadProgressStream.listen((event) { onSendProgress(event.loaded, event.total); @@ -147,13 +148,13 @@ class BrowserHttpClientAdapter implements HttpClientAdapter { } else { if (sendTimeout > Duration.zero) { warningLog( - 'sendTimeout cannot be used without a request body to send', + 'sendTimeout cannot be used without a request body to send on Web', StackTrace.current, ); } - if (options.onSendProgress != null) { + if (onSendProgress != null) { warningLog( - 'onSendProgress cannot be used without a request body to send', + 'onSendProgress cannot be used without a request body to send on Web', StackTrace.current, ); } From dfafd4ea866cdf75247a66c3886f3d2f69a49e53 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Mon, 7 Oct 2024 10:24:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9D=20CHANGELOG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dio/CHANGELOG.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dio/CHANGELOG.md b/dio/CHANGELOG.md index e319e0ed4..3ff5268d3 100644 --- a/dio/CHANGELOG.md +++ b/dio/CHANGELOG.md @@ -5,13 +5,12 @@ See the [Migration Guide][] for the complete breaking changes list.** ## Unreleased -*None.* +- Removes redundant warnings when composing request options on Web. ## 5.7.0 -- Graceful handling of responses with nonzero `Content-Length`, `Content-Type` json, but empty body - - Empty responses are now transformed to `null` - +- Graceful handling of responses with nonzero `Content-Length`, `Content-Type` that is json, and empty payload. + - Empty responses are now transformed to `null`. ## 5.6.0