writeContent method

Future<CacheResponse> writeContent(
  1. CacheOptions options, {
  2. Response? response,
})

Implementation

Future<CacheResponse> writeContent(
  CacheOptions options, {
  Response? response,
}) async {
  if (response != null) {
    return copyWith(
      content: await CacheCipher.encryptContent(
        options,
        await serializeContent(
          response.requestOptions.responseType,
          response.data,
        ),
      ),
      headers: await CacheCipher.encryptContent(
        options,
        utf8.encode(jsonEncode(response.headers.map)),
      ),
    );
  }

  return copyWith(
    content: await CacheCipher.encryptContent(options, content),
    headers: await CacheCipher.encryptContent(options, headers),
  );
}