Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add client id #85

Merged
merged 1 commit into from
Aug 9, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions QiniuSDK/QiniuUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,23 @@
return [NSError errorWithDomain:kQiniuErrorDomain code:errorCode userInfo:userInfo];
}

static NSString* clientId(){
long long now_timestamp = [[NSDate date] timeIntervalSince1970]*1000;
int r = arc4random()%1000;
return [NSString stringWithFormat:@"%lld%u", now_timestamp, r];
}

static NSString* _clientId = nil;

NSString *qiniuUserAgent() {
return [NSString stringWithFormat:@"Qiniu-iOS/%@ (%@; iOS %@; )", kQiniuVersion, [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion]];
if (_clientId == nil){
_clientId = clientId();
}
return [NSString stringWithFormat:@"Qiniu-iOS/%@ (%@; iOS %@; %@)", kQiniuVersion, [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], _clientId];
}

BOOL isRetryHost(AFHTTPRequestOperation *operation) {

NSInteger errorCode = [operation.response statusCode];

if (errorCode / 100 == 4 || errorCode / 100 == 6 || errorCode / 100 == 7) {
Expand Down