开发者

How use User-Agent to make iPhone download file as a chrome?

My code is:

NSMutableURLRequest* req = [[[NSMutableURLRequest alloc] initWithURL:url]
                                autorelease];

NSString *userAgent = @"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13";    
[req setValue:userAgent forHTTPHeaderField:@"User-Agent"];

NSURLResponse* response = nil;
NSError* error = nil;
NSData* fff = [NSURLConnection sendSynchronousRequest:req
                                     returningRespon开发者_运维问答se:&response
                                                 error:&error];

NSLog(@"size : %d", [fff length]);

I prepare to make iPhone download file as chrome. But it doesn't work! I don't know why...


This userAgent String works: "Mozilla/5.0 (iPhone; U; CPU OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/4.0 Mobile/8C148 Safari/533.17"; Use the Swizzle classes.

By the way.. your string: @"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13"; Has Windows; U; Windows NT 5.1 in there and that's not what you want for an iphone

David

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜