Committed by
Ben Copsey
Don't step on a previously-specified user-agent
Signed-off-by: Ben Copsey <ben@allseeing-i.com>
Showing
1 changed file
with
16 additions
and
14 deletions
@@ -391,20 +391,22 @@ static NSError *ASITooMuchRedirectionError; | @@ -391,20 +391,22 @@ static NSError *ASITooMuchRedirectionError; | ||
391 | 391 | ||
392 | // Set a logical user agent (on iPhones, for now) | 392 | // Set a logical user agent (on iPhones, for now) |
393 | #if TARGET_OS_IPHONE | 393 | #if TARGET_OS_IPHONE |
394 | - UIDevice *device = [UIDevice currentDevice]; | 394 | + if ([[self requestHeaders] objectForKey:@"User-Agent"] == nil) { |
395 | - NSBundle *bundle = [NSBundle mainBundle]; | 395 | + UIDevice *device = [UIDevice currentDevice]; |
396 | - NSLocale *locale = [NSLocale currentLocale]; | 396 | + NSBundle *bundle = [NSBundle mainBundle]; |
397 | - | 397 | + NSLocale *locale = [NSLocale currentLocale]; |
398 | - NSString *userAgent = [NSString stringWithFormat:@"%@ %@ (%@; %@ %@; %@)", | 398 | + |
399 | - [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"], | 399 | + NSString *userAgent = [NSString stringWithFormat:@"%@ %@ (%@; %@ %@; %@)", |
400 | - [bundle objectForInfoDictionaryKey:@"CFBundleVersion"], | 400 | + [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"], |
401 | - [device model], | 401 | + [bundle objectForInfoDictionaryKey:@"CFBundleVersion"], |
402 | - [device systemName], | 402 | + [device model], |
403 | - [device systemVersion], | 403 | + [device systemName], |
404 | - [locale localeIdentifier] | 404 | + [device systemVersion], |
405 | - ]; | 405 | + [locale localeIdentifier] |
406 | - | 406 | + ]; |
407 | - [self addRequestHeader:@"User-Agent" value:userAgent]; | 407 | + |
408 | + [self addRequestHeader:@"User-Agent" value:userAgent]; | ||
409 | + } | ||
408 | #endif | 410 | #endif |
409 | 411 | ||
410 | // Accept a compressed response | 412 | // Accept a compressed response |
-
Please register or login to post a comment