|
@@ -496,7 +496,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
int noSigPipe = 1;
|
|
|
setsockopt(socket, SOL_SOCKET, SO_NOSIGPIPE, &noSigPipe, sizeof(noSigPipe)); // Make sure this socket cannot generate SIG_PIPE
|
|
|
|
|
|
- GCDWebServerConnection* connection = [[_connectionClass alloc] initWithServer:self localAddress:localAddress remoteAddress:remoteAddress socket:socket]; // Connection will automatically retain itself while opened
|
|
|
+ GCDWebServerConnection* connection = [(GCDWebServerConnection*)[_connectionClass alloc] initWithServer:self localAddress:localAddress remoteAddress:remoteAddress socket:socket]; // Connection will automatically retain itself while opened
|
|
|
[connection self]; // Prevent compiler from complaining about unused variable / useless statement
|
|
|
} else {
|
|
|
GWS_LOG_ERROR(@"Failed accepting %s socket: %s (%i)", isIPv6 ? "IPv6" : "IPv4", strerror(errno), errno);
|
|
@@ -509,9 +509,9 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
- (BOOL)_start:(NSError**)error {
|
|
|
GWS_DCHECK(_source4 == NULL);
|
|
|
|
|
|
- NSUInteger port = [_GetOption(_options, GCDWebServerOption_Port, @0) unsignedIntegerValue];
|
|
|
- BOOL bindToLocalhost = [_GetOption(_options, GCDWebServerOption_BindToLocalhost, @NO) boolValue];
|
|
|
- NSUInteger maxPendingConnections = [_GetOption(_options, GCDWebServerOption_MaxPendingConnections, @16) unsignedIntegerValue];
|
|
|
+ NSUInteger port = [(NSNumber*)_GetOption(_options, GCDWebServerOption_Port, @0) unsignedIntegerValue];
|
|
|
+ BOOL bindToLocalhost = [(NSNumber*)_GetOption(_options, GCDWebServerOption_BindToLocalhost, @NO) boolValue];
|
|
|
+ NSUInteger maxPendingConnections = [(NSNumber*)_GetOption(_options, GCDWebServerOption_MaxPendingConnections, @16) unsignedIntegerValue];
|
|
|
|
|
|
struct sockaddr_in addr4;
|
|
|
bzero(&addr4, sizeof(addr4));
|
|
@@ -545,17 +545,17 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
return NO;
|
|
|
}
|
|
|
|
|
|
- _serverName = [_GetOption(_options, GCDWebServerOption_ServerName, NSStringFromClass([self class])) copy];
|
|
|
+ _serverName = [(NSString*)_GetOption(_options, GCDWebServerOption_ServerName, NSStringFromClass([self class])) copy];
|
|
|
NSString* authenticationMethod = _GetOption(_options, GCDWebServerOption_AuthenticationMethod, nil);
|
|
|
if ([authenticationMethod isEqualToString:GCDWebServerAuthenticationMethod_Basic]) {
|
|
|
- _authenticationRealm = [_GetOption(_options, GCDWebServerOption_AuthenticationRealm, _serverName) copy];
|
|
|
+ _authenticationRealm = [(NSString*)_GetOption(_options, GCDWebServerOption_AuthenticationRealm, _serverName) copy];
|
|
|
_authenticationBasicAccounts = [[NSMutableDictionary alloc] init];
|
|
|
NSDictionary* accounts = _GetOption(_options, GCDWebServerOption_AuthenticationAccounts, @{});
|
|
|
[accounts enumerateKeysAndObjectsUsingBlock:^(NSString* username, NSString* password, BOOL* stop) {
|
|
|
[_authenticationBasicAccounts setObject:_EncodeBase64([NSString stringWithFormat:@"%@:%@", username, password]) forKey:username];
|
|
|
}];
|
|
|
} else if ([authenticationMethod isEqualToString:GCDWebServerAuthenticationMethod_DigestAccess]) {
|
|
|
- _authenticationRealm = [_GetOption(_options, GCDWebServerOption_AuthenticationRealm, _serverName) copy];
|
|
|
+ _authenticationRealm = [(NSString*)_GetOption(_options, GCDWebServerOption_AuthenticationRealm, _serverName) copy];
|
|
|
_authenticationDigestAccounts = [[NSMutableDictionary alloc] init];
|
|
|
NSDictionary* accounts = _GetOption(_options, GCDWebServerOption_AuthenticationAccounts, @{});
|
|
|
[accounts enumerateKeysAndObjectsUsingBlock:^(NSString* username, NSString* password, BOOL* stop) {
|
|
@@ -563,9 +563,9 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
}];
|
|
|
}
|
|
|
_connectionClass = _GetOption(_options, GCDWebServerOption_ConnectionClass, [GCDWebServerConnection class]);
|
|
|
- _shouldAutomaticallyMapHEADToGET = [_GetOption(_options, GCDWebServerOption_AutomaticallyMapHEADToGET, @YES) boolValue];
|
|
|
- _disconnectDelay = [_GetOption(_options, GCDWebServerOption_ConnectedStateCoalescingInterval, @1.0) doubleValue];
|
|
|
- _dispatchQueuePriority = [_GetOption(_options, GCDWebServerOption_DispatchQueuePriority, @(DISPATCH_QUEUE_PRIORITY_DEFAULT)) longValue];
|
|
|
+ _shouldAutomaticallyMapHEADToGET = [(NSNumber*)_GetOption(_options, GCDWebServerOption_AutomaticallyMapHEADToGET, @YES) boolValue];
|
|
|
+ _disconnectDelay = [(NSNumber*)_GetOption(_options, GCDWebServerOption_ConnectedStateCoalescingInterval, @1.0) doubleValue];
|
|
|
+ _dispatchQueuePriority = [(NSNumber*)_GetOption(_options, GCDWebServerOption_DispatchQueuePriority, @(DISPATCH_QUEUE_PRIORITY_DEFAULT)) longValue];
|
|
|
|
|
|
_source4 = [self _createDispatchSourceWithListeningSocket:listeningSocket4 isIPv6:NO];
|
|
|
_source6 = [self _createDispatchSourceWithListeningSocket:listeningSocket6 isIPv6:YES];
|
|
@@ -596,7 +596,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ([_GetOption(_options, GCDWebServerOption_RequestNATPortMapping, @NO) boolValue]) {
|
|
|
+ if ([(NSNumber*)_GetOption(_options, GCDWebServerOption_RequestNATPortMapping, @NO) boolValue]) {
|
|
|
DNSServiceErrorType status = DNSServiceNATPortMappingCreate(&_dnsService, 0, 0, kDNSServiceProtocol_TCP, htons(port), htons(port), 0, _DNSServiceCallBack, (__bridge void*)self);
|
|
|
if (status == kDNSServiceErr_NoError) {
|
|
|
CFSocketContext context = {0, (__bridge void*)self, NULL, NULL, NULL};
|
|
@@ -872,7 +872,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
if (![requestMethod isEqualToString:method]) {
|
|
|
return nil;
|
|
|
}
|
|
|
- return [[aClass alloc] initWithMethod:requestMethod url:requestURL headers:requestHeaders path:urlPath query:urlQuery];
|
|
|
+ return [(GCDWebServerRequest*)[aClass alloc] initWithMethod:requestMethod url:requestURL headers:requestHeaders path:urlPath query:urlQuery];
|
|
|
}
|
|
|
asyncProcessBlock:block];
|
|
|
}
|
|
@@ -895,7 +895,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
if ([urlPath caseInsensitiveCompare:path] != NSOrderedSame) {
|
|
|
return nil;
|
|
|
}
|
|
|
- return [[aClass alloc] initWithMethod:requestMethod url:requestURL headers:requestHeaders path:urlPath query:urlQuery];
|
|
|
+ return [(GCDWebServerRequest*)[aClass alloc] initWithMethod:requestMethod url:requestURL headers:requestHeaders path:urlPath query:urlQuery];
|
|
|
}
|
|
|
asyncProcessBlock:block];
|
|
|
} else {
|
|
@@ -938,7 +938,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- GCDWebServerRequest* request = [[aClass alloc] initWithMethod:requestMethod url:requestURL headers:requestHeaders path:urlPath query:urlQuery];
|
|
|
+ GCDWebServerRequest* request = [(GCDWebServerRequest*)[aClass alloc] initWithMethod:requestMethod url:requestURL headers:requestHeaders path:urlPath query:urlQuery];
|
|
|
[request setAttribute:captures forKey:GCDWebServerRequestAttribute_RegexCaptures];
|
|
|
return request;
|
|
|
}
|