From 1cb40733532865e62252e254622cb9bdb6810e2a Mon Sep 17 00:00:00 2001 From: choykarl <253440030@qq.com> Date: Mon, 1 Apr 2024 23:37:59 +0800 Subject: [PATCH] fix baidu translate (#482) Co-authored-by: Tisfeng --- Easydict/Feature/Service/Baidu/EZBaiduTranslate.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Easydict/Feature/Service/Baidu/EZBaiduTranslate.m b/Easydict/Feature/Service/Baidu/EZBaiduTranslate.m index f950fe217..2b7b2adc4 100644 --- a/Easydict/Feature/Service/Baidu/EZBaiduTranslate.m +++ b/Easydict/Feature/Service/Baidu/EZBaiduTranslate.m @@ -115,6 +115,9 @@ - (AFHTTPSessionManager *)jsonSession { - (NSString *)cookie { NSString *cookie = [[NSUserDefaults standardUserDefaults] stringForKey:kBaiduTranslateURL] ?: @"BAIDUID=0F8E1A72A51EE47B7CA0A81711749C00:FG=1;"; + if (![cookie containsString:@"smallFlowVersion=old"]) { + cookie = [NSString stringWithFormat:@"%@%@", cookie, @";smallFlowVersion=old;"]; + } return cookie; } @@ -767,6 +770,7 @@ - (void)sendGetTokenAndGtkRequestWithCompletion:(void (^)(NSString *_Nullable to // set headers for (NSString *key in headers.allKeys) { [self.jsonSession.requestSerializer setValue:headers[key] forHTTPHeaderField:key]; + [self.htmlSession.requestSerializer setValue:headers[key] forHTTPHeaderField:key]; } [self.htmlSession GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask *_Nonnull task, id _Nullable responseObject) {