mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-26 17:43:22 +01:00
Add UserAgent.headers() function — otherwise that code was duplicated in a couple places.
This commit is contained in:
parent
fa0d355ab0
commit
07e6ff5572
@ -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]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user