dio_smart_retry icon indicating copy to clipboard operation
dio_smart_retry copied to clipboard

RetryInterceptor changes responseType to json

Open danielcmm opened this issue 1 year ago • 0 comments

Hi!

I dont know if im doing something wrong, but if i set the responseType to ResponseType.plain and the RetryInterceptor is executed after a timeout, the interceptor seems to set the responseType to ResponseType.json.

Example:

``

final dio = Dio(
  BaseOptions(
    baseUrl: rootUri,
    connectTimeout: 3000,
    receiveTimeout: 5000,
    headers: headers,
    responseType: ResponseType.plain,
  ),
);

dio.interceptors.add(
  RetryInterceptor(
    dio: dio,
    logPrint: log, // specify log function (optional)
    retryDelays: const [
      Duration(seconds: 3), // wait 1 sec before first retry
      Duration(seconds: 5), // wait 2 sec before second retry
      Duration(seconds: 10), // wait 3 sec before third retry
    ],
  ),
);

try {
  response = await dio.get(url);
...

If there is no timeout, everything works fine.

Any ideas?

Thanks!

danielcmm avatar Sep 13 '22 05:09 danielcmm