Skip to content

Commit cbbc737

Browse files
authored
Merge branch 'flymzero:main' into main
2 parents 557304b + 5a8dd0d commit cbbc737

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
### [1.2.2]
4+
- 302 redirect: redirect to the real link. Thanks [@cmlanche](https://github.com/flymzero/webdav_client/pull/46)
5+
36
### [1.2.1]
47
- Dio Dependency Update
58

lib/src/webdav_dio.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,25 @@ class WdDio with DioMixin implements Dio {
132132
onReceiveProgress: onReceiveProgress,
133133
cancelToken: cancelToken,
134134
);
135+
} else if (resp.statusCode == 302) {
136+
// 文件位置被重定向到新路径
137+
if (resp.headers.map.containsKey('location')) {
138+
List<String>? list = resp.headers.map['location'];
139+
if (list != null && list.isNotEmpty) {
140+
String redirectPath = list[0];
141+
// retry
142+
return this.req<T>(
143+
self,
144+
method,
145+
redirectPath,
146+
data: data,
147+
optionsHandler: optionsHandler,
148+
onSendProgress: onSendProgress,
149+
onReceiveProgress: onReceiveProgress,
150+
cancelToken: cancelToken,
151+
);
152+
}
153+
}
135154
}
136155

137156
return resp;

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: webdav_client
22
description: A simple WebDAV client that supports some common methods.
33

4-
version: 1.2.1
4+
version: 1.2.2
55
homepage: https://github.com/flymzero/webdav_client
66

77
environment:

0 commit comments

Comments
 (0)