From 57aeab7987d188a75b9c05047a175bad144e925a Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Thu, 24 Feb 2022 21:54:04 -0800 Subject: [PATCH] Avoid disabling the DDG user agent for the Suggestions service. --- .../Common/Extensions/URLRequestExtension.swift | 12 ++---------- .../Suggestions/Model/SuggestionContainer.swift | 3 +-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/DuckDuckGo/Common/Extensions/URLRequestExtension.swift b/DuckDuckGo/Common/Extensions/URLRequestExtension.swift index 9fd33ab49b..ec38b94e9e 100644 --- a/DuckDuckGo/Common/Extensions/URLRequestExtension.swift +++ b/DuckDuckGo/Common/Extensions/URLRequestExtension.swift @@ -27,8 +27,7 @@ extension URLRequest { case referer = "Referer" } - // Note: Change the user agent to macOS version before the release - static func defaultRequest(with url: URL, useDuckDuckGoUserAgent: Bool = true) -> URLRequest { + static func defaultRequest(with url: URL) -> URLRequest { var request = URLRequest(url: url) request.setValue("gzip;q=1.0, compress;q=0.5", forHTTPHeaderField: HeaderKey.acceptEncoding.rawValue) @@ -36,14 +35,7 @@ extension URLRequest { let appVersion = AppVersion.shared.versionNumber let appId = AppVersion.shared.identifier let systemVersion = ProcessInfo.processInfo.operatingSystemVersion - - let userAgent: String - - if useDuckDuckGoUserAgent { - userAgent = "ddg_macos/\(appVersion) (\(appId); macOS \(systemVersion))" - } else { - userAgent = UserAgent.fallbackWebViewDefault - } + let userAgent = "ddg_macos/\(appVersion) (\(appId); macOS \(systemVersion))" request.setValue(userAgent, forHTTPHeaderField: HeaderKey.userAgent.rawValue) diff --git a/DuckDuckGo/Suggestions/Model/SuggestionContainer.swift b/DuckDuckGo/Suggestions/Model/SuggestionContainer.swift index fe649f845f..072fa684ff 100644 --- a/DuckDuckGo/Suggestions/Model/SuggestionContainer.swift +++ b/DuckDuckGo/Suggestions/Model/SuggestionContainer.swift @@ -106,8 +106,7 @@ extension SuggestionContainer: SuggestionLoadingDataSource { } } - // The DuckDuckGo user agent is disabled for AC requests until there is enough volume from the browser. - var request = URLRequest.defaultRequest(with: url, useDuckDuckGoUserAgent: false) + var request = URLRequest.defaultRequest(with: url) request.timeoutInterval = 1 suggestionsURLSession.dataTask(with: request) { (data, _, error) in