GCDWebServer / GCDWebUploader

GCDWebServer 不支持  HTTPS
GCDWebServer 支持 Basic / Digest Authenticate

如果想在 GCDWebServer 上添加 Login 功能,可行的方法是:
开启 Digest Authenticate


- (BOOL)startWithPort:(NSUInteger)port bonjourName:(NSString*)name { NSMutableDictionary* options = [NSMutableDictionarydictionary];
[optionssetObject:[NSNumbernumberWithInteger:port]forKey:GCDWebServerOption_Port];[optionssetValue:nameforKey:GCDWebServerOption_BonjourName];[optionssetValue:GCDWebServerAuthenticationMethod_DigestAccessforKey:GCDWebServerOption_AuthenticationMethod];
[optionssetValue:[NSDictionarydictionaryWithObjectsAndKeys:@"pass",@"admin",nil]forKey:GCDWebServerOption_AuthenticationAccounts];
return[selfstartWithOptions:optionserror:NULL];
}

添加这两行:
[optionssetValue:GCDWebServerAuthenticationMethod_DigestAccessforKey:GCDWebServerOption_AuthenticationMethod];
[optionssetValue:[NSDictionarydictionaryWithObjectsAndKeys:@"pass",@"admin",nil]forKey:GCDWebServerOption_AuthenticationAccounts];

比较简单的方法。不过, nonce 超时好像 GCDWebServer 做的不太好,也就是登录了之后,拷贝URL地址,再启动一个浏览器线程,直接打开刚才复制的页面URL 还是可以打开的。

不知道超时是多久,也没找到设置超时的地方,按道理应该每一个request 都有一个 nonce 的。

再研究研究

你可能感兴趣的:(GCDWebServer / GCDWebUploader)