3

does NSURLSession send user-agent automatically has an answer that describes the NSURLSession default HTTP User-Agent string for iOS. I want to know the default format for macOS (preferably with supporting documentation), and the default format for NSURLConnection as well.

I'm seeing some very old User-Agent strings on my site, and I'm trying to verify potential sources.

Heath Borders
  • 30,998
  • 16
  • 147
  • 256

1 Answers1

5

It follows that same code path as the iOS one.

nsurl/887 CFNetwork/887 Darwin/17.0.0 (x86_64)

$(CFBundleName)/$(CFBundleVersion) CFNetwork/$(CFNetworkVersion) Darwin/$(DarwinVersion) ($(Architecture))

If the program doesn't have a CFBundleName, its executable name is used instead. For missing CFBundleVersion, (unknown version) is used. This typically occurs when a command line tool without a bundle calls CFNetwork.

I don't think there is any documentation for this, and the default User Agent should be treated as a debugging facility instead of a specified behavior.

Guoye Zhang
  • 499
  • 4
  • 9
  • Thanks. I'm just looking for some kind of external supporting content from someone at Apple. An openradar, a tweet, or a mailing list post would be fine as well. – Heath Borders Oct 15 '17 at 12:05
  • 2
    I interned in CFNetwork team during the summer and read the code that generated User-Agent. I don’t think anyone touched it for the last decade or so, therefore it should be rather stable – Guoye Zhang Oct 16 '17 at 13:32