Ben Copsey

Hopefully make SOCKS proxies work

... ... @@ -333,6 +333,10 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
NSString *proxyHost;
int proxyPort;
// ASIHTTPRequest will assume kCFProxyTypeHTTP if the proxy type could not be automatically determined
// Set to kCFProxyTypeSOCKS if you are manually configuring a SOCKS proxy
NSString *proxyType;
// URL for a PAC (Proxy Auto Configuration) file. If you want to set this yourself, it's probably best if you use a local file
NSURL *PACurl;
... ... @@ -749,6 +753,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
@property (retain) NSString *proxyHost;
@property (assign) int proxyPort;
@property (retain) NSString *proxyType;
@property (retain,setter=setURL:) NSURL *url;
@property (retain) NSURL *originalURL;
... ...
... ... @@ -24,7 +24,7 @@
// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.7-4 2010-06-30";
NSString *ASIHTTPRequestVersion = @"v1.7-5 2010-06-30";
NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
... ... @@ -936,17 +936,35 @@ static NSOperationQueue *sharedQueue = nil;
NSDictionary *settings = [proxies objectAtIndex:0];
[self setProxyHost:[settings objectForKey:(NSString *)kCFProxyHostNameKey]];
[self setProxyPort:[[settings objectForKey:(NSString *)kCFProxyPortNumberKey] intValue]];
[self setProxyType:[settings objectForKey:(NSString *)kCFProxyTypeKey]];
}
}
if ([self proxyHost] && [self proxyPort]) {
NSString *hostKey = (NSString *)kCFStreamPropertyHTTPProxyHost;
NSString *portKey = (NSString *)kCFStreamPropertyHTTPProxyPort;
if ([[[[self url] scheme] lowercaseString] isEqualToString:@"https"]) {
hostKey = (NSString *)kCFStreamPropertyHTTPSProxyHost;
portKey = (NSString *)kCFStreamPropertyHTTPSProxyPort;
NSString *hostKey;
NSString *portKey;
if (![self proxyType]) {
[self setProxyType:(NSString *)kCFProxyTypeHTTP];
}
if ([[self proxyType] isEqualToString:(NSString *)kCFProxyTypeSOCKS]) {
hostKey = (NSString *)kCFStreamPropertySOCKSProxyHost;
portKey = (NSString *)kCFStreamPropertySOCKSProxyPort;
} else {
hostKey = (NSString *)kCFStreamPropertyHTTPProxyHost;
portKey = (NSString *)kCFStreamPropertyHTTPProxyPort;
if ([[[[self url] scheme] lowercaseString] isEqualToString:@"https"]) {
hostKey = (NSString *)kCFStreamPropertyHTTPSProxyHost;
portKey = (NSString *)kCFStreamPropertyHTTPSProxyPort;
}
}
NSMutableDictionary *proxyToUse = [NSMutableDictionary dictionaryWithObjectsAndKeys:[self proxyHost],hostKey,[NSNumber numberWithInt:[self proxyPort]],portKey,nil];
CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPProxy, proxyToUse);
if ([[self proxyType] isEqualToString:(NSString *)kCFProxyTypeSOCKS]) {
CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySOCKSProxy, proxyToUse);
} else {
CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPProxy, proxyToUse);
}
}
//
... ... @@ -3996,6 +4014,7 @@ static NSOperationQueue *sharedQueue = nil;
@synthesize proxyCredentials;
@synthesize proxyHost;
@synthesize proxyPort;
@synthesize proxyType;
@synthesize PACurl;
@synthesize authenticationScheme;
@synthesize proxyAuthenticationScheme;
... ...