opt: request get options

This commit is contained in:
guozhigq
2024-11-13 00:54:49 +08:00
parent 449630c770
commit 57407c943f
3 changed files with 11 additions and 16 deletions

View File

@ -209,24 +209,12 @@ class Request {
*/
get(url, {data, Options? options, cancelToken, extra}) async {
Response response;
options ??= Options(); // 如果 options 为 null则初始化一个新的 Options 对象
ResponseType resType = ResponseType.json;
if (extra != null) {
resType = extra['resType'] ?? ResponseType.json;
if (extra['ua'] != null) {
options.headers = {'user-agent': headerUa(type: extra['ua'])};
}
if (extra['opus-goback'] != null) {
if (extra['opus-goback'] != null) {
String cookieHeader = dio.options.headers['cookie'];
options.headers!['cookie'] =
'$cookieHeader; opus-goback = ${extra['opus-goback']}';
}
options ??= Options();
options.headers!['user-agent'] = headerUa(type: extra['ua']);
}
}
options.responseType = resType;
try {
response = await dio.get(
url,