sendRequest method

  1. @override
Future<VoltronHttpResponse> sendRequest(
  1. VoltronHttpRequest request
)
override

send request

Implementation

@override
Future<VoltronHttpResponse> sendRequest(VoltronHttpRequest request) async {
  var headers = _fillHeader(request);
  var dio = Dio(
    BaseOptions(
      method: request.method,
      connectTimeout: request.connectTimeout,
      receiveTimeout: request.receiveTimeout,
      sendTimeout: request.sendTimeout,
      headers: headers,
      followRedirects: request.followRedirects,
    ),
  );
  dio.interceptors.add(channel.CookieManager.getInstance());
  var dioResponse = await dio.request(request.url, data: request.body);
  return VoltronHttpResponse(
    statusCode: dioResponse.statusCode ?? VoltronHttpResponse.unknownStatus,
    statusMessage: dioResponse.statusMessage ?? '',
    headerMap: normalizeResponseHeader(dioResponse.headers.map),
    requestOptions: dioResponse.requestOptions,
    data: dioResponse.data,
  );
}