feat: brotli support.

This commit is contained in:
Aunali321 2022-10-09 23:01:10 +05:30
parent 4dfa0dada6
commit 0df2a6bdc0
3 changed files with 14 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:dio/dio.dart';
import 'package:dio_brotli_transformer/dio_brotli_transformer.dart';
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:injectable/injectable.dart';
@ -11,7 +12,12 @@ import 'package:revanced_manager/models/patch.dart';
@lazySingleton
class GithubAPI {
final Dio _dio = Dio(
BaseOptions(baseUrl: 'https://api.github.com'),
BaseOptions(
baseUrl: 'https://api.github.com',
headers: {
'accept-encoding': 'br',
},
),
)..httpClientAdapter = NativeAdapter();
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final Options _cacheOptions = buildCacheOptions(
@ -31,6 +37,7 @@ class GithubAPI {
void initialize() {
_dio.interceptors.add(_dioCacheManager.interceptor);
_dio.transformer = DioBrotliTransformer(transformer: DefaultTransformer());
}
Future<void> clearAllCache() async {

View File

@ -1,5 +1,6 @@
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:dio_brotli_transformer/dio_brotli_transformer.dart';
import 'package:native_dio_client/native_dio_client.dart';
import 'package:dio/dio.dart';
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
@ -20,9 +21,13 @@ class RevancedAPI {
Future<void> initialize(String apiUrl) async {
_dio = Dio(BaseOptions(
baseUrl: apiUrl,
headers: {
'accept-encoding': 'br',
},
))
..httpClientAdapter = NativeAdapter();
_dio.interceptors.add(_dioCacheManager.interceptor);
_dio.transformer = DioBrotliTransformer(transformer: DefaultTransformer());
}
Future<void> clearAllCache() async {

View File

@ -20,6 +20,7 @@ dependencies:
ref: revanced-manager
device_info_plus: ^4.1.2
dio: ^4.0.6
dio_brotli_transformer: ^1.0.1
dio_http_cache_lts: ^0.4.1
dynamic_color: ^1.5.4
dynamic_themes: ^1.1.0