Skip to content

Commit b68d0b7

Browse files
committed
Add statusMessage attribute for Response
1 parent 47de5ea commit b68d0b7

File tree

4 files changed

+65
-53
lines changed

4 files changed

+65
-53
lines changed

CHANGELOG.md

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,3 @@
1+
## Change Log:
12

2-
# 2.0
3-
4-
**Refactor the Interceptors**
5-
- Support add Multiple Interceptors.
6-
- Add Log Interceptor
7-
- Add CookieManager Interceptor
8-
9-
**API**
10-
- Support Uri
11-
- Support `queryParameters` for all request API
12-
- Modify the `get` API
13-
14-
**Options**
15-
- Separate Options to three class: Options、BaseOptions、RequestOptions
16-
- Add `queryParameters` and `cookies` for BaseOptions
17-
18-
**Adapter**
19-
- Abstract HttpClientAdapter layer.
20-
- Provide a DefaultHttpClientAdapter which make http requests by `dart:io:HttpClient`
21-
22-
## 0.1.8
23-
24-
- change file name "TransFormer" to "Transformer"
25-
- change "dio.transFormer" to "dio.transformer"
26-
- change deprecated "UTF8" to "utf8"
27-
28-
## 0.1.5
29-
30-
- add `clear` method for dio instance
31-
32-
## 0.1.4
33-
34-
- fix `download` bugs
35-
36-
## 0.1.3
37-
38-
- support upload files with Array
39-
- support create `HttpClient` by user self in `onHttpClientCreate`
40-
- support generic
41-
- bug fix
42-
43-
## 0.0.1
44-
45-
- Initial version, created by Stagehand
3+
See https://github.com/flutterchina/dio/blob/master/package_src/CHANGELOG.md

package_src/CHANGELOG.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1-
## Change Log:
1+
# 2.1.3
22

3-
See https://github.com/flutterchina/dio/blob/master/CHANGELOG.md
3+
Add `statusMessage` attribute for `Response` and `ResponseBody`
4+
5+
# 2.1.2
6+
7+
First Stable version for 2.x
8+
9+
# 2.0
10+
11+
**Refactor the Interceptors**
12+
- Support add Multiple Interceptors.
13+
- Add Log Interceptor
14+
- Add CookieManager Interceptor
15+
16+
**API**
17+
- Support Uri
18+
- Support `queryParameters` for all request API
19+
- Modify the `get` API
20+
21+
**Options**
22+
- Separate Options to three class: Options、BaseOptions、RequestOptions
23+
- Add `queryParameters` and `cookies` for BaseOptions
24+
25+
**Adapter**
26+
- Abstract HttpClientAdapter layer.
27+
- Provide a DefaultHttpClientAdapter which make http requests by `dart:io:HttpClient`
28+
29+
## 0.1.8
30+
31+
- change file name "TransFormer" to "Transformer"
32+
- change "dio.transFormer" to "dio.transformer"
33+
- change deprecated "UTF8" to "utf8"
34+
35+
## 0.1.5
36+
37+
- add `clear` method for dio instance
38+
39+
## 0.1.4
40+
41+
- fix `download` bugs
42+
43+
## 0.1.3
44+
45+
- support upload files with Array
46+
- support create `HttpClient` by user self in `onHttpClientCreate`
47+
- support generic
48+
- bug fix
49+
50+
## 0.0.1
51+
52+
- Initial version, created by Stagehand

package_src/lib/src/dio.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,15 +710,18 @@ class Dio {
710710
// If the return type is Error, we should throw it
711711
if (data is Error) throw _assureDioError(data);
712712
var r = _assureResponse<T>(data);
713-
r.request = r.request ?? requestOptions;
713+
714714
response = r;
715715
}
716716
return response;
717717
}).catchError((err) => throw _assureDioError(err));
718718
});
719719

720720
return await _listenCancelForAsyncTask<Response<T>>(cancelToken, future)
721-
.catchError((e) {
721+
.then((r) {
722+
r.request = r.request ?? requestOptions;
723+
return r;
724+
}).catchError((e) {
722725
throw e..request = e.request ?? requestOptions;
723726
});
724727
}
@@ -743,7 +746,7 @@ class Dio {
743746
Response ret = new Response(
744747
headers: responseBody.headers,
745748
request: options,
746-
redirects: responseBody.redirects??[],
749+
redirects: responseBody.redirects ?? [],
747750
statusCode: responseBody.statusCode,
748751
statusMessage: responseBody.statusMessage,
749752
extra: responseBody.extra,
@@ -1006,6 +1009,8 @@ class Dio {
10061009
headers: response.headers,
10071010
request: response.request,
10081011
statusCode: response.statusCode,
1012+
redirects: response.redirects,
1013+
statusMessage: response.statusMessage,
10091014
);
10101015
}
10111016
return response;

package_src/lib/src/interceptors/log.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class LogInterceptor extends Interceptor {
4343

4444
if (request) {
4545
printKV('method', options.method);
46-
printKV('contentType', options.contentType.toString());
47-
printKV('responseType', options.responseType.toString());
46+
printKV('contentType', options.contentType?.toString());
47+
printKV('responseType', options.responseType?.toString());
4848
printKV('followRedirects', options.followRedirects);
4949
printKV('connectTimeout', options.connectTimeout);
5050
printKV('receiveTimeout', options.receiveTimeout);
@@ -81,13 +81,13 @@ class LogInterceptor extends Interceptor {
8181
}
8282

8383
void _printResponse(Response response) {
84-
printKV('uri', response.request.uri);
84+
printKV('uri', response?.request?.uri);
8585
if (responseHeader) {
8686
printKV('statusCode', response.statusCode);
8787
if(response.isRedirect)
8888
printKV('redirect',response.realUri);
8989
print("headers:");
90-
print(" " + response.headers.toString().replaceAll("\n", "\n "));
90+
print(" " + response?.headers?.toString()?.replaceAll("\n", "\n "));
9191
}
9292
if (responseBody) {
9393
print("Response Text:");

0 commit comments

Comments
 (0)