mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-01-11 22:40:36 +00:00
34 lines
906 B
Dart
34 lines
906 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:mangayomi/eval/javascript/http.dart';
|
|
import 'package:mangayomi/eval/lib.dart';
|
|
import 'package:mangayomi/services/http/m_client.dart';
|
|
import 'package:mangayomi/utils/utils.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
part 'headers.g.dart';
|
|
|
|
@riverpod
|
|
Map<String, String> headers(
|
|
Ref ref, {
|
|
required String source,
|
|
required String lang,
|
|
}) {
|
|
final mSource = getSource(lang, source);
|
|
|
|
Map<String, String> headers = {};
|
|
|
|
if (mSource != null) {
|
|
final fromSource = mSource.headers;
|
|
|
|
if (fromSource != null && fromSource.isNotEmpty) {
|
|
headers.addAll((jsonDecode(fromSource) as Map).toMapStringString!);
|
|
}
|
|
|
|
headers.addAll(getExtensionService(mSource).getHeaders());
|
|
headers.addAll(MClient.getCookiesPref(mSource.baseUrl!));
|
|
}
|
|
|
|
return headers;
|
|
}
|