< prev index next >
src/java.base/windows/native/libnet/DefaultProxySelector.c
Print this page
*** 32,45 ****
#include "proxy_util.h"
#include "sun_net_spi_DefaultProxySelector.h"
! /**
* These functions are used by the sun.net.spi.DefaultProxySelector class
* to access some platform specific settings.
! * This is the Windows code using WinHTTP functions to get the system settings.
*/
/* Keep one static session for all requests. */
static HINTERNET session = NULL;
--- 32,45 ----
#include "proxy_util.h"
#include "sun_net_spi_DefaultProxySelector.h"
! /*
* These functions are used by the sun.net.spi.DefaultProxySelector class
* to access some platform specific settings.
! * On Windows use WinHTTP functions to get the system settings.
*/
/* Keep one static session for all requests. */
static HINTERNET session = NULL;
*** 50,61 ****
*/
JNIEXPORT jboolean JNICALL
Java_sun_net_spi_DefaultProxySelector_init(JNIEnv *env, jclass clazz) {
/*
! * Get one WinHTTP session handle to initialize the WinHTTP internal data structures
! * We keep and use only this one for the whole life time.
*/
session = WinHttpOpen(L"Only used internal", /* we need no real agent string here */
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS,
--- 50,61 ----
*/
JNIEXPORT jboolean JNICALL
Java_sun_net_spi_DefaultProxySelector_init(JNIEnv *env, jclass clazz) {
/*
! * Get one WinHTTP session handle to initialize the WinHTTP internal data
! * structures. Keep and use only this one for the whole life time.
*/
session = WinHttpOpen(L"Only used internal", /* we need no real agent string here */
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS,
*** 105,115 ****
wchar_t *context = NULL;
wchar_t *current_proxy = NULL;
BOOL error = FALSE;
/*
! * The proxy server list contains one or more of the following strings separated by semicolons or whitespace.
* ([<scheme>=][<scheme>"://"]<server>[":"<port>])
*/
current_proxy = wcstok_s(win_proxy, separators, &context);
while (current_proxy != NULL) {
LPWSTR pport;
--- 105,116 ----
wchar_t *context = NULL;
wchar_t *current_proxy = NULL;
BOOL error = FALSE;
/*
! * The proxy server list contains one or more of the following strings
! * separated by semicolons or whitespace:
* ([<scheme>=][<scheme>"://"]<server>[":"<port>])
*/
current_proxy = wcstok_s(win_proxy, separators, &context);
while (current_proxy != NULL) {
LPWSTR pport;
*** 255,285 ****
/* Check the bypass entry. */
if (NULL != win_bypass_proxy) {
/*
* From MSDN:
! * The proxy bypass list contains one or more server names separated by semicolons or
! * whitespace. The proxy bypass list can also contain the string "<local>" to indicate
! * that all local intranet sites are bypassed. Local intranet sites are considered to
! * be all servers that do not contain a period in their name.
*/
wchar_t *context = NULL;
LPWSTR s = wcstok_s(win_bypass_proxy, L"; ", &context);
while (s != NULL) {
size_t maxlen = wcslen(s);
if (wcsncmp(s, lpHost, maxlen) == 0) {
/*
! * The URL host name matches with one of the prefixes, we have to use a direct
! * connection.
*/
goto noproxy;
}
if (wcsncmp(s, L"<local>", maxlen) == 0) {
/*
! * All local intranet sites are bypassed - Microsoft considers all servers that
! * do not contain a period in their name to be local.
*/
if (wcschr(lpHost, '.') == NULL) {
goto noproxy;
}
}
--- 256,287 ----
/* Check the bypass entry. */
if (NULL != win_bypass_proxy) {
/*
* From MSDN:
! * The proxy bypass list contains one or more server names separated by
! * semicolons or whitespace. The proxy bypass list can also contain the
! * string "<local>" to indicate that all local intranet sites are
! * bypassed. Local intranet sites are considered to be all servers that
! * do not contain a period in their name.
*/
wchar_t *context = NULL;
LPWSTR s = wcstok_s(win_bypass_proxy, L"; ", &context);
while (s != NULL) {
size_t maxlen = wcslen(s);
if (wcsncmp(s, lpHost, maxlen) == 0) {
/*
! * The URL host name matches with one of the prefixes, use a
! * direct connection.
*/
goto noproxy;
}
if (wcsncmp(s, L"<local>", maxlen) == 0) {
/*
! * All local intranet sites are bypassed - Microsoft consider all
! * servers that do not contain a period in their name to be local.
*/
if (wcschr(lpHost, '.') == NULL) {
goto noproxy;
}
}
*** 290,302 ****
if (win_proxy != NULL) {
wchar_t *context = NULL;
int defport = 0;
int nr_elems = 0;
! /**
! * Set default port value & proxy type from protocol.
! */
if ((wcscmp(lpProto, L"http") == 0) ||
(wcscmp(lpProto, L"ftp") == 0) ||
(wcscmp(lpProto, L"gopher") == 0))
defport = 80;
if (wcscmp(lpProto, L"https") == 0)
--- 292,302 ----
if (win_proxy != NULL) {
wchar_t *context = NULL;
int defport = 0;
int nr_elems = 0;
! /* Set the default port value & proxy type from protocol. */
if ((wcscmp(lpProto, L"http") == 0) ||
(wcscmp(lpProto, L"ftp") == 0) ||
(wcscmp(lpProto, L"gopher") == 0))
defport = 80;
if (wcscmp(lpProto, L"https") == 0)
< prev index next >