Hi,
I've created an application and set the User-Agent string like so:
class GlobalUtils: NSObject {
static let UserAgentString : String = "HttpClientSample"
static let UserAgentVersion : String = "1.0"
}let config = URLSessionConfiguration.default
config.httpAdditionalHeaders = ["User-Agent": "\(GlobalUtils.UserAgentVersion)/\(GlobalUtils.UserAgentVersion)"]
let defaultSession : URLSession = URLSession(configuration: config, delegate: self.CurrentSession!, delegateQueue: OperationQueue.main)However, I find that sometimes the user-agent appears to be in the format as
$CFBundleName$/$Version$ CFNetwork/976 Darwin/18.20.0
Do you know in what cases this would occur and how to control this behavior? When this occurs my HTTP requests don't go through the proxy server because they don't match my User-Agent.
Thanks,
Dave
Thanks for the clarification.
Are you sure that the problematic request was from a task created in your session? It’s very easy to accidentally reference
URLSession.shared rather than
self.defaultSession (or whatever) and you’ll see this behaviour.
How reproducible is this?
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"