我正在为 iOS 应用程序尝试 SPDY,该应用程序当前使用 AFNetworking (2.1.0) 来处理 HTTP 请求。服务器端,我使用的是 Google App Engine(使用SPDYCheck检查)它是 SPDY 友好的。
这是我在代码中集成 SPDY 的方式。
我正在使用 AFHTTPRequestOperationManager
@interface MyClient : AFHTTPRequestOperationManager
我将 SPDY 嵌入到initWithBaseURL:
- (id)initWithBaseURL:(NSURL *)url {
self = [super initWithBaseURL:url];
if (!self) {
return nil;
}
// SPDY Config
NSString *spdyURL = [NSString stringWithFormat:@"%@://%@:443",url.scheme, url.host];
[SPDYURLConnectionProtocol registerOrigin:spdyURL];
...
}
请注意,我的网址是格式https://myapp.appspot.com/_ah/
所以我在传递给 SPDY 时重新格式化registerOrigin:
spdyURL 看起来像https://myapp.appspot.com:443
我想这就是我所需要的?但是添加 SPDY 代码后我无法发送请求。调试消息显示以下错误:
error response from api/users/v1/is_token_valid :
Error Domain=NSURLErrorDomain
Code=-1001
"The request timed out."
UserInfo=0xdc2c250 {NSErrorFailingURLStringKey=https://myapp.appspot.com/_ah/api/users/v1/is_token_valid?
user_token=[a_token],
NSErrorFailingURLKey=https://myapp.appspot.com/_ah/api/users/v1/is_token_valid?
user_token=[a_token],
NSLocalizedDescription=The request timed out., NSUnderlyingError=0xf270e60 "The request timed out."}
我一点头绪都没有。希望有在 iOS 上使用 SPDY 经验的人可以提供帮助!