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.)
Completely twisted: create a local socket on port 80 and make a local request (to yourself), read the HTTP headers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With