I want to programmatically retrieve my application’s User-Agent
string. (Note: not the UA of a UIWebView in my application; the UA for NSURLConnection
-based HTTP requests.)
There’s lots of guides on how to read an application's UIWebView
User-Agent
, but none on how to get at the <appname>/1.0 CFNetwork/456.23
string that CFNetwork
stuffs inside its HTTP requests. There’s API for CFHTTPMessage
to copy out all header fields, but I only have an NSURLRequest
and an NSURLResponse
, and these are unbridged opaque types. Help!
(Some good background reading: Changing the userAgent of NSURLConnection mentions the format that I want to get at. What HTTP User-Agent does my iOS program advertise itself as? does as well.)