Andy Fowler
Committed by Ben Copsey

Adds a User-Agent header in iPhone apps. Tried to slightly emulate the Mobile Safari user agent.

Formatted like:
MyAppName 1.0 (iPhone Simulator; iPhone OS 3.0; en_US)

Signed-off-by: Ben Copsey <ben@allseeing-i.com>
... ... @@ -389,6 +389,23 @@ static NSError *ASITooMuchRedirectionError;
}
}
// Set a logical user agent (on iPhones, for now)
#if TARGET_OS_IPHONE
UIDevice *device = [UIDevice currentDevice];
NSBundle *bundle = [NSBundle mainBundle];
NSLocale *locale = [NSLocale currentLocale];
NSString *userAgent = [NSString stringWithFormat:@"%@ %@ (%@; %@ %@; %@)",
[bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"],
[bundle objectForInfoDictionaryKey:@"CFBundleVersion"],
[device model],
[device systemName],
[device systemVersion],
[locale localeIdentifier]
];
[self addRequestHeader:@"User-Agent" value:userAgent];
#endif
// Accept a compressed response
if ([self allowCompressedResponse]) {
... ...