这是官方我见过的最怪异的事情。 我有一个iPhone 5和iPhone 5S,无论在iOS 7.1.2,彻底干净。 我运行下面的代码:
NSString *userAgent = @"Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3";
NSURL *url = [NSURL URLWithString: deviceString];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:url];
[request setValue:userAgent forHTTPHeaderField:@"User-Agent"];
NSHTTPURLResponse *response = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSDictionary *dict = [response allHeaderFields];
NSLog(@"Status code: %d",[response statusCode]);
NSLog(@"Headers:\n %@",dict.description);
NSLog(@"Error: %@",error.description);
NSLog(@"Response data: %@",[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
在iPhone 5S返回我正在寻找正确的网页源代码,而同样一个我从模拟器获得。 标题是这样的:
"Alternate-Protocol" = "80:quic";
"Cache-Control" = "no-cache";
"Content-Encoding" = gzip;
"Content-Length" = 5627;
"Content-Type" = "text/plain; charset=utf-8";
Date = "Fri, 01 Aug 2014 17:21:40 GMT";
Expires = "Tue, 27 Apr 1971 19:44:06 EST";
P3P = "CP=\"This is not a P3P policy! See http://support.google.com/accounts/bin/answer.py?answer=151657&hl=en for more info.\"";
Server = "gwiseguy/2.0";
"Set-Cookie" = "YSC=oohlyqgkgwg; path=/; domain=.youtube.com; httponly";
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = SAMEORIGIN;
"X-XSS-Protection" = "1; mode=block; report=https://www.google.com/appserve/security-bugs/log/youtube";
而iPhone 5将返回不同的东西,并且你可以从Content-Length头看到显著短:
"Alternate-Protocol" = "80:quic";
"Cache-Control" = "no-cache";
"Content-Length" = 767;
"Content-Type" = "text/html; charset=utf-8";
Date = "Fri, 01 Aug 2014 17:23:06 GMT";
Expires = "Tue, 27 Apr 1971 19:44:06 EST";
P3P = "CP=\"This is not a P3P policy! See http://support.google.com/accounts/bin/answer.py?answer=151657&hl=en for more info.\"";
Server = "gwiseguy/2.0";
"Set-Cookie" = "YSC=2KFSqyO4p1k; path=/; domain=.youtube.com; httponly";
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = SAMEORIGIN;
"X-XSS-Protection" = "1; mode=block; report=https://www.google.com/appserve/security-bugs/log/youtube";
我糊涂了。
编辑:
现在我已经发现了iPhone 5的正常工作的一个iPhone 5S不是!? 我们正在测试相同的WiFi网络上,但手机被AT&T和Verizon的服务之间的分裂。 1 Verizon正在工作时,有些则没有。 所有的AT&T正在工作。
更新:
我已经解决了这个问题。 现在,我需要一些帮助理解我所做的:/我注意到标题之间的差异行"Content-Encoding" = gzip
所以我把我的这行代码:
[request setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];
现在要求按预期工作,但为什么我需要做的是什么? 我还没有过去,这不是一个新的功能。