From 94e439ab524ef587cc2919376deaa8c9754ad68c Mon Sep 17 00:00:00 2001 From: duwen Date: Tue, 12 Feb 2019 13:36:46 +0800 Subject: [PATCH] support OnUploadProgress --- lib/src/dio.dart | 4 ++-- lib/src/form_data.dart | 3 ++- pubspec.yaml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/dio.dart b/lib/src/dio.dart index b637f8746..607db121f 100644 --- a/lib/src/dio.dart +++ b/lib/src/dio.dart @@ -43,7 +43,7 @@ class Dio { } /// The Dio version. - static const version = "1.0.16"; + static const version = "1.0.17"; /// Default Request config. More see [Options] . Options options; @@ -501,6 +501,7 @@ class Dio { Future> future = _checkIfNeedEnqueue(interceptor.request, () { _mergeOptions(options); + options.data = data; options.path = path; // If user provide a request interceptor, enter the interceptor. InterceptorCallback preSend = interceptor.request.onSend; @@ -820,7 +821,6 @@ class Dio { opt.connectTimeout ??= options.connectTimeout ?? 0; opt.receiveTimeout ??= options.receiveTimeout ?? 0; opt.responseType ??= options.responseType ?? ResponseType.JSON; - opt.data ??= options.data; opt.extra = (new Map.from(options.extra))..addAll(opt.extra); opt.contentType ??= options.contentType ?? ContentType.json; opt.validateStatus ??= options.validateStatus ?? diff --git a/lib/src/form_data.dart b/lib/src/form_data.dart index 0cbb77463..3b50feb85 100644 --- a/lib/src/form_data.dart +++ b/lib/src/form_data.dart @@ -79,6 +79,7 @@ class FormData extends MapMixin { } _appendTextField(data, key, value, bytes); }); + //int length=bytes.length; fileMap.forEach((key, fileInfo) { if(fileInfo is UploadFileInfo) { _appendFileContent(data,key, fileInfo, bytes); @@ -92,11 +93,11 @@ class FormData extends MapMixin { }); } }); + if (_map.length > 0 || fileMap.length > 0) { data.clear(); data.write(boundary+"--"); _writeln(data); - //_writeln(data); bytes.addAll(utf8.encode(data.toString())); } return bytes; diff --git a/pubspec.yaml b/pubspec.yaml index cd7bc8330..47f37fb58 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dio description: A powerful Http client for Dart, which supports Interceptors, FormData, Request Cancellation, File Downloading, Timeout etc. -version: 1.0.16 +version: 1.0.17 homepage: https://github.com/flutterchina/dio author: wendux <824783146@qq.com>