mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-24 12:30:12 +08:00
mod: retry
This commit is contained in:
committed by
bggRGjQaUbCoE
parent
f8226fcade
commit
0a7f18a035
@@ -1,5 +1,6 @@
|
|||||||
import 'package:PiliPlus/http/init.dart';
|
import 'package:PiliPlus/http/init.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:http2/http2.dart';
|
||||||
|
|
||||||
class RetryInterceptor extends Interceptor {
|
class RetryInterceptor extends Interceptor {
|
||||||
final int _count;
|
final int _count;
|
||||||
@@ -50,7 +51,10 @@ class RetryInterceptor extends Interceptor {
|
|||||||
case DioExceptionType.connectionTimeout:
|
case DioExceptionType.connectionTimeout:
|
||||||
case DioExceptionType.sendTimeout:
|
case DioExceptionType.sendTimeout:
|
||||||
case DioExceptionType.unknown:
|
case DioExceptionType.unknown:
|
||||||
if ((err.requestOptions.extra['_rt'] ??= 0) < _count) {
|
if ((err.requestOptions.extra['_rt'] ??= 0) < _count &&
|
||||||
|
err.error
|
||||||
|
is! TransportConnectionException // 网络中断, 此时请求可能已经被服务器所接收
|
||||||
|
) {
|
||||||
Future.delayed(
|
Future.delayed(
|
||||||
Duration(
|
Duration(
|
||||||
milliseconds: ++err.requestOptions.extra['_rt'] * _delay,
|
milliseconds: ++err.requestOptions.extra['_rt'] * _delay,
|
||||||
|
|||||||
Reference in New Issue
Block a user