From 07e6ff557231066a01d8c04913130162bc648a72 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 7 Oct 2017 12:34:12 -0700 Subject: [PATCH] =?UTF-8?q?Add=20UserAgent.headers()=20function=20?= =?UTF-8?q?=E2=80=94=20otherwise=20that=20code=20was=20duplicated=20in=20a?= =?UTF-8?q?=20couple=20places.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/RSWeb/RSWeb/UserAgent.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Frameworks/RSWeb/RSWeb/UserAgent.swift b/Frameworks/RSWeb/RSWeb/UserAgent.swift index 1d9fc29e9..38dd52cbf 100755 --- a/Frameworks/RSWeb/RSWeb/UserAgent.swift +++ b/Frameworks/RSWeb/RSWeb/UserAgent.swift @@ -8,9 +8,9 @@ import Foundation -public class UserAgent { +public struct UserAgent { - public class func fromInfoPlist() -> String? { + public static func fromInfoPlist() -> String? { guard let userAgentName = Bundle.main.object(forInfoDictionaryKey: "UserAgent") else { return nil @@ -20,4 +20,13 @@ public class UserAgent { } return "\(userAgentName) \(version)" } + + public static func headers() -> [AnyHashable: String]? { + + guard let userAgent = fromInfoPlist() else { + return nil + } + + return [HTTPRequestHeader.userAgent: userAgent] + } }