< prev index next >
src/java.base/macosx/native/libnet/DefaultProxySelector.c
Print this page
*** 59,96 ****
}
CFRunLoopStop(CFRunLoopGetCurrent());
}
/*
! * This will resolve all PAC URLs in the given array and return an array containing no more
! * PAC URLs.
*/
static CFArrayRef createExpandedProxiesArray(CFArrayRef proxies, CFURLRef url) {
CFIndex count;
CFIndex index;
CFMutableArrayRef expandedProxiesArray;
expandedProxiesArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
! assert(expandedProxiesArray != NULL);
/* Iterate over the array of proxies */
count = CFArrayGetCount(proxies);
for (index = 0; index < count ; index++) {
CFDictionaryRef currentProxy;
CFStringRef proxyType;
currentProxy = (CFDictionaryRef) CFArrayGetValueAtIndex(proxies, index);
! assert(currentProxy != NULL);
proxyType = (CFStringRef) CFDictionaryGetValue(currentProxy, kCFProxyTypeKey);
! assert(proxyType != NULL);
if (!CFEqual(proxyType, kCFProxyTypeAutoConfigurationURL)) {
! /* This is a non PAC entry - just copy it to the new array. */
CFArrayAppendValue(expandedProxiesArray, currentProxy);
} else {
! /* This is a PAC URL and we have to resolve it. */
CFRunLoopSourceRef runLoop;
CFURLRef scriptURL;
CFTypeRef result = NULL;
CFStreamClientContext context = { 0, &result, NULL, NULL, NULL };
--- 59,105 ----
}
CFRunLoopStop(CFRunLoopGetCurrent());
}
/*
! * Returns a new array of proxies containing all the given non-PAC proxies as
! * well as the results of executing all the given PAC-based proxies, for the
! * specified URL. 'proxies' is a list that may contain both PAC and non-PAC
! * proxies.
*/
static CFArrayRef createExpandedProxiesArray(CFArrayRef proxies, CFURLRef url) {
CFIndex count;
CFIndex index;
CFMutableArrayRef expandedProxiesArray;
expandedProxiesArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
! if (expandedProxiesArray == NULL)
! return NULL;
/* Iterate over the array of proxies */
count = CFArrayGetCount(proxies);
for (index = 0; index < count ; index++) {
CFDictionaryRef currentProxy;
CFStringRef proxyType;
currentProxy = (CFDictionaryRef) CFArrayGetValueAtIndex(proxies, index);
! if(currentProxy == NULL) {
! CFRelease(expandedProxiesArray);
! return NULL;
! }
proxyType = (CFStringRef) CFDictionaryGetValue(currentProxy, kCFProxyTypeKey);
! if (proxyType == NULL) {
! CFRelease(expandedProxiesArray);
! return NULL;
! }
if (!CFEqual(proxyType, kCFProxyTypeAutoConfigurationURL)) {
! /* Non-PAC entry, just copy it to the new array */
CFArrayAppendValue(expandedProxiesArray, currentProxy);
} else {
! /* PAC-based URL, execute its script append its results */
CFRunLoopSourceRef runLoop;
CFURLRef scriptURL;
CFTypeRef result = NULL;
CFStreamClientContext context = { 0, &result, NULL, NULL, NULL };
*** 107,124 ****
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoop, kResolveProxyRunLoopMode);
CFRunLoopRunInMode(kResolveProxyRunLoopMode, 1.0e10, false);
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runLoop, kResolveProxyRunLoopMode);
/*
! * Once the runloop returns, we should have either an error result or a
! * proxies array result. Do the appropriate thing with that result.
*/
if (result != NULL) {
if (CFGetTypeID(result) == CFArrayGetTypeID()) {
/*
! * Append the new array from the PAC list - it does
! * contain no more PAC URIs.
*/
CFArrayAppendArray(expandedProxiesArray, result,
CFRangeMake(0, CFArrayGetCount(result)));
}
CFRelease(result);
--- 116,133 ----
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoop, kResolveProxyRunLoopMode);
CFRunLoopRunInMode(kResolveProxyRunLoopMode, 1.0e10, false);
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runLoop, kResolveProxyRunLoopMode);
/*
! * Once the runloop returns, there will be either an error result or
! * a proxies array result. Do the appropriate thing with that result.
*/
if (result != NULL) {
if (CFGetTypeID(result) == CFArrayGetTypeID()) {
/*
! * Append the new array from the PAC list - it contains
! * only non-PAC entries.
*/
CFArrayAppendArray(expandedProxiesArray, result,
CFRangeMake(0, CFArrayGetCount(result)));
}
CFRelease(result);
*** 203,212 ****
--- 212,227 ----
CFIndex index;
CFArrayRef expandedProxyArray = createExpandedProxiesArray(urlProxyArrayRef, urlRef);
CFRelease(urlProxyArrayRef);
+ if (expandedProxyArray == NULL) {
+ CFRelease(urlRef);
+ CFRelease(proxyDicRef);
+ return NULL;
+ }
+
count = CFArrayGetCount(expandedProxyArray);
proxyArray = (*env)->NewObjectArray(env, count, proxy_class, NULL);
if (proxyArray != NULL || (*env)->ExceptionCheck(env)) {
/* Iterate over the expanded array of proxies */
*** 217,235 ****
currentProxy = (CFDictionaryRef) CFArrayGetValueAtIndex(expandedProxyArray,
index);
proxyType = (CFStringRef) CFDictionaryGetValue(currentProxy, kCFProxyTypeKey);
if (CFEqual(proxyType, kCFProxyTypeNone)) {
! /*
! * This entry states we should use no proxy - therefor we just create a
! * NO_PROXY object.
! */
proxy = (*env)->GetStaticObjectField(env, proxy_class, pr_no_proxyID);
} else {
/*
! * Create a proxy object for this entry. We have to differentiate between
! * socks and http type.
*/
jfieldID typeID = ptype_httpID;
if (CFEqual(proxyType, kCFProxyTypeSOCKS)) {
typeID = ptype_socksID;
}
--- 232,247 ----
currentProxy = (CFDictionaryRef) CFArrayGetValueAtIndex(expandedProxyArray,
index);
proxyType = (CFStringRef) CFDictionaryGetValue(currentProxy, kCFProxyTypeKey);
if (CFEqual(proxyType, kCFProxyTypeNone)) {
! /* This entry states no proxy, therefore just add a NO_PROXY object. */
proxy = (*env)->GetStaticObjectField(env, proxy_class, pr_no_proxyID);
} else {
/*
! * Create a proxy object for this entry.
! * Differentiate between SOCKS and HTTP type.
*/
jfieldID typeID = ptype_httpID;
if (CFEqual(proxyType, kCFProxyTypeSOCKS)) {
typeID = ptype_socksID;
}
< prev index next >