Skip to content

Commit

Permalink
adding a more meaningful user agent string
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafa committed Mar 26, 2013
1 parent b26a25d commit 7e8bf6b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion evernote-sdk-ios/3rdParty/Thrift/transport/THTTPClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (void) setupRequest

NSString * userAgent = mUserAgent;
if (!userAgent) {
userAgent = @"Cocoa/THTTPClient";
userAgent = [THTTPClient createClientVersionString];
}
[mRequest setValue: userAgent forHTTPHeaderField: @"User-Agent"];

Expand Down Expand Up @@ -193,5 +193,23 @@ - (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long total
[self setDownloadProgressBlock:block];
}

+ (NSString *)createClientVersionString
{
NSString * clientName = nil;
NSString * locale = [NSString stringWithFormat: @"%@",
[[NSLocale currentLocale] objectForKey: NSLocaleCountryCode]];

NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *appName = [infoDic valueForKey:(id)kCFBundleNameKey];
NSString * buildVersion = [infoDic valueForKey: @"SourceVersion"];
if (buildVersion == nil) {
buildVersion = [infoDic valueForKey:(id)kCFBundleVersionKey];
}
clientName = [NSString stringWithFormat: @"%@ iPhone/%@ (%@);",
appName,
buildVersion,
locale];
return clientName;
}

@end

0 comments on commit 7e8bf6b

Please sign in to comment.