mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-27 10:02:37 +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