• asi 网络框架


    
    将凭据存储到钥匙链 
    NSURL *url = [NSURL URLWithString:@"http://www.dreamingwish.com/"];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setUseKeychainPersistence:YES];
    [request setUsername:@"username"];
    [request setPassword:@"password"];
    
    将凭据存储到session
    [request setUseSessionPersistence:YES];
    
    cookie
    清空cookie	 [ASIHTTPRequest setSessionCookies:nil];
    
    //创建一个cookie
    NSDictionary *properties = [[[NSMutableDictionary alloc] init] autorelease];
    [properties setValue:[@"Test Value" encodedCookieValue] forKey:NSHTTPCookieValue];
    [properties setValue:@"ASIHTTPRequestTestCookie" forKey:NSHTTPCookieName];
    [properties setValue:@".dreamingwish.com" forKey:NSHTTPCookieDomain];
    [properties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60] forKey:NSHTTPCookieExpires];
    [properties setValue:@"/asi-http-request/tests" forKey:NSHTTPCookiePath];
    NSHTTPCookie *cookie = [[[NSHTTPCookie alloc] initWithProperties:properties] autorelease];
    
    
    [request setUseCookiePersistence:NO];
    [request setRequestCookies:[NSMutableArray arrayWithObject:cookie]];
    
    
    客户端证书:
    // Will send the certificate attached to the identity (identity is a SecIdentityRef)
    [request setClientCertificateIdentity:identity];
      
    // Add an additional certificate (where cert is a SecCertificateRef)
    [request setClientCertificates:[NSArray arrayWithObject:(id)cert]];
    
    
    
    代理链接 setProxyHost setProxyPort setProxyUsername  setProxyPassword setProxyDomain
    
    证书校验 setValidatesSecureCertificate 
    
    流量控制
    // 这将会对WWAN连接下的request进行流量控制(控制到预定义的值)
    // Wi-Fi连接下的 request不会受影响
    // 这个方法仅在iOS上可用
    [ASIHTTPRequest setShouldThrottleBandwidthForWWAN:YES];
      
    // 这将会对WWAN连接下的request进行流量控制(控制到自定义的值)
    // 这个方法仅在iOS上可用
    [ASIHTTPRequest throttleBandwidthForWWANUsingLimit:14800];
      
    // 这将会控移动应用(mobile applications)的流量到预定义的值.
    // 会限制所有requests, 不管request是不是WiFi连接下的 - <strong>使用时要注意</strong>
    [ASIHTTPRequest setMaxBandwidthPerSecond:ASIWWANBandwidthThrottleAmount];
      
    // 记录每秒有多少字节的流量 (过去5秒内的平均值)
    NSLog(@"%qi",[ASIHTTPRequest averageBandwidthUsedPerSecond]);
    
    
    
    持久链接 
    	[request setRequestMethod:@"PUT"];    [request setShouldAttemptPersistentConnection:YES];
    	// 设置持久连接的超时时间为120秒
    	[request setPersistentConnectionTimeoutSeconds:120];
      
    	// 彻底禁用持久连接
    	[request setShouldAttemptPersistentConnection:NO];
    
  • 相关阅读:
    C++17 filesystem文件系统
    简易版本vue的实现
    javaSE基础04
    javaSE基础03
    javaSE基础02
    JavaSE基础01
    Document对象和window对象
    进程和子进程及端口的常用命令
    vue分页组件二次封装---每页请求特定数据
    css图片垂直水平居中及放大(实现水平垂直居中的效果有哪些方法?)
  • 原文地址:https://www.cnblogs.com/dqxu/p/4353294.html
Copyright © 2020-2023  润新知