求助贴 哪位大大能知道下UIWebView设置代理服务器(Proxy)呢,获取视频的URL

u010959582 2016-12-15 07:31:19
最近公司想要做个浏览器,浏览器主要是为了统计用户访问地址,希望用户的访问走代理服务器,从而分配用户合理的资源

然而国内并没有太好的方案,倒是在论坛看到了使用AFNetworking设置Web的网络代理了(传送门http://stackoverflow.com/questions/28361357/handling-redirects-with-custom-nsurlprotocol-and-http-proxy),主要代码如下:
/**
* 配置代理的一些信息
*/
- (NSURLSessionConfiguration *)setProxyWithConfiger {
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
config.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
config.connectionProxyDictionary = [self setProxyDictWithCFHTTPStream];

return config;
}


/**
* 配置代理属性
*
* 使用的是 CFHTTPStream.h 的一些属性,但是不支持 enale, 采用 NSString 方式填写
*
* enable属性是否可以采用kCFNetworkProxiesHTTPEnable代替,但是 HTTPS 不支持
*
* @return 属性配置字典
*/
- (NSDictionary *)setProxyDictWithCFHTTPStream {

NSString *ip = [[NSUserDefaults standardUserDefaults] stringForKey:@"ipString"];
NSString *port = [[NSUserDefaults standardUserDefaults] stringForKey:@"portString"];

NSInteger portInt = [port integerValue];

NSDictionary *dict = @{
@"HTTPEnable" : @YES,
(id)kCFStreamPropertyHTTPProxyHost:ip,
(id)kCFStreamPropertyHTTPProxyPort:@(portInt),
@"HTTPSEnable" : @YES,
(id)kCFStreamPropertyHTTPSProxyHost:ip,
(id)kCFStreamPropertyHTTPSProxyPort:@(portInt)
};
NSLog(@"setProxyDictWithCFHTTPStream----%@",dict);
return dict;
}

但是以上方法只是在首次load时候走代理,再次加载则是走的系统的请求,在UIWebViewDelegate的代理方法shouldStartLoadWithRequest中过滤下内容,再次进行请求
if (navigationType == UIWebViewNavigationTypeLinkClicked || navigationType == UIWebViewNavigationTypeFormSubmitted || navigationType == UIWebViewNavigationTypeFormResubmitted
|| navigationType == UIWebViewNavigationTypeReload || navigationType == UIWebViewNavigationTypeBackForward) {


[self loadURL:[request URL]];


return NO;
}


return YES;,结果是不能获取到播放视频的东西包,抓包失败了,不知道如何抓到视频的url呢。。求助啊~
...全文
325 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧