intercept method

  1. @override
Future<ZResponse> intercept(
  1. Chain<ZRequest, Future<ZResponse>> chain
)
override

拦截处理

Implementation

@override
Future<ZResponse> intercept(Chain<ZRequest, Future<ZResponse>> chain) async {
  var request = chain.input();
  var response = await chain.process(request);
  if (request.options?.responseType == dio.ResponseType.bytes) {
    String? charset;
    response.response?.headers
        .value('Content-Type')
        ?.split(';')
        .forEach((value) {
      if (value.contains('charset')) {
        charset = value.split('=')[1];
      }
    });
    response.charset = charset;
  }
  return response;
}