opt: post redirect (#788)

* opt: cookie

* opt: post redirect
This commit is contained in:
My-Responsitories
2025-05-01 10:08:48 +08:00
committed by GitHub
parent a46bde68f5
commit c090cae1a1
5 changed files with 68 additions and 67 deletions

View File

@@ -164,10 +164,8 @@ class Request {
: http11Adapter;
// 先于其他Interceptor
if (GStorage.retryCount > 0) {
dio.interceptors
.add(RetryInterceptor(GStorage.retryCount, GStorage.retryDelay));
}
dio.interceptors
.add(RetryInterceptor(GStorage.retryCount, GStorage.retryDelay));
// 日志拦截器 输出请求、响应内容
if (BuildConfig.isDebug) {
@@ -222,7 +220,7 @@ class Request {
* post请求
*/
Future<Response> post(url,
{data, queryParameters, options, cancelToken, isRedirect}) async {
{data, queryParameters, options, cancelToken}) async {
// debugPrint('post-data: $data');
Response response;
try {
@@ -236,20 +234,6 @@ class Request {
// debugPrint('post success: ${response.data}');
return response;
} on DioException catch (e) {
if (isRedirect != true &&
const [301, 302, 303, 307, 308].contains(e.response?.statusCode)) {
String? redirectUrl = e.response?.headers['location']?.firstOrNull;
if (redirectUrl != null) {
return await post(
redirectUrl,
data: data,
queryParameters: queryParameters,
options: options,
cancelToken: cancelToken,
isRedirect: true,
);
}
}
AccountManager.toast(e);
Response errResponse = Response(
data: {