当前位置: 首页>>代码示例>>Java>>正文


Java ProxyConfig类代码示例

本文整理汇总了Java中com.gargoylesoftware.htmlunit.ProxyConfig的典型用法代码示例。如果您正苦于以下问题:Java ProxyConfig类的具体用法?Java ProxyConfig怎么用?Java ProxyConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ProxyConfig类属于com.gargoylesoftware.htmlunit包,在下文中一共展示了ProxyConfig类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provideWebClient

import com.gargoylesoftware.htmlunit.ProxyConfig; //导入依赖的package包/类
@Provides
protected WebClient provideWebClient()
{
	WebClient webClient = new WebClient();

	String proxyHost = config.getProperty("ws.proxy.host");
	String proxyPort = config.getProperty("ws.proxy.port");
	if (proxyHost != null && !"".equals(proxyHost) && proxyPort != null && !"".equals(proxyPort))
	{
		ProxyConfig proxyConfig = new ProxyConfig(proxyHost, Integer.parseInt(proxyPort));
		webClient.getOptions().setProxyConfig(proxyConfig);
	}

	webClient.getOptions().setActiveXNative(false);
	webClient.getOptions().setJavaScriptEnabled(false);
	webClient.getOptions().setCssEnabled(false);
	webClient.getOptions().setUseInsecureSSL(true);

	return webClient;
}
 
开发者ID:mqlibrary,项目名称:alma-toolkit,代码行数:21,代码来源:ToolkitModule.java

示例2: setUp

import com.gargoylesoftware.htmlunit.ProxyConfig; //导入依赖的package包/类
@BeforeClass
  public static void setUp() throws InterruptedException {
      log.debug("setUp");
      webClient = new WebClient();
WebClientOptions options = webClient.getOptions();
options.setPrintContentOnFailingStatusCode(true);
options.setJavaScriptEnabled(true);
      webClient.setHTMLParserListener(HTMLParserListener.LOG_REPORTER);
      webClient.setAjaxController(new NicelyResynchronizingAjaxController());
      ProxyConfig proxy = new ProxyConfig("p-goodway.rd.francetelecom.fr", 3128);
      proxy.addHostsToProxyBypass("127.0.0.1");
options.setProxyConfig(proxy);
  }
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:14,代码来源:BaseHmlUnit.java

示例3: setProxy

import com.gargoylesoftware.htmlunit.ProxyConfig; //导入依赖的package包/类
public static void setProxy(WebClient webClient,String host,int port) {
	ProxyConfig proxyConfig = webClient.getOptions().getProxyConfig();
	proxyConfig.setProxyHost(host);
	proxyConfig.setProxyPort(port);
	//DefaultCredentialsProvider credentialsProvider = (DefaultCredentialsProvider) webClient.getCredentialsProvider();
	//credentialsProvider.addCredentials(proxy.getUser(), proxy.getPassword());
}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:8,代码来源:HtmlUnitUtil.java

示例4: setProxyBasedOnSystemProperties

import com.gargoylesoftware.htmlunit.ProxyConfig; //导入依赖的package包/类
/**
 * <p>This is the system variable we will look for to parse the Proxy configuration.</p>
 * <p>TODO: There are default system properties for this? (proxy.host, proxy.port).</p>
 * 
 * <p>Format: &lt;host&gt;:&lt;port&gt; (so, <code>localhost:8080</code> for example).</p>
 */
public static void setProxyBasedOnSystemProperties() {
    final Logger logger = LoggerFactory.getLogger(WebClientFactory.class);
    String proxyString = System.getProperty(PROXY_CONFIG);
    if (proxyString == null) {
        logger.info("No proxy configured via system property '{}'", PROXY_CONFIG);
    } else {
        logger.info("Using a proxy: {}", proxyString);
        try {
            proxy = new ProxyConfig(proxyString.split(":")[0], Integer.parseInt(proxyString.split(":")[1]));
        } catch (Exception e) {
            logger.error("Error parsing proxyString: {}", proxyString, e);
        }
    }
}
 
开发者ID:forcedotcom,项目名称:SiteCrawler,代码行数:21,代码来源:WebClientFactory.java

示例5: setProxy

import com.gargoylesoftware.htmlunit.ProxyConfig; //导入依赖的package包/类
synchronized void setProxy()
{
    if(!(proxy.equals("")||port.equals("")))
    {
        ProxyConfig pgg=new ProxyConfig(proxy,Integer.parseInt(port));
        webClient.setProxyConfig(pgg);
        pgg=null;
    }
    if(puser!=""&&ppass!="")
    {
        credentialsProvider.addCredentials(puser,ppass);
    }
}
 
开发者ID:ayushmaanbhav,项目名称:iitpwebapp,代码行数:14,代码来源:IITPWebMail.java

示例6: LinkedInOAuthRequestFilter

import com.gargoylesoftware.htmlunit.ProxyConfig; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public LinkedInOAuthRequestFilter(OAuthParams oAuthParams, Map<String, Object> httpParams,
                                  boolean lazyAuth, String[] enabledProtocols) {

    this.oAuthParams = oAuthParams;
    this.oAuthToken = null;

    // create HtmlUnit client
    webClient = new WebClient(BrowserVersion.FIREFOX_38);
    final WebClientOptions options = webClient.getOptions();
    options.setRedirectEnabled(true);
    options.setJavaScriptEnabled(false);
    options.setThrowExceptionOnFailingStatusCode(true);
    options.setThrowExceptionOnScriptError(true);
    options.setPrintContentOnFailingStatusCode(LOG.isDebugEnabled());
    options.setSSLClientProtocols(enabledProtocols);

    // add HTTP proxy if set
    if (httpParams != null && httpParams.get(ConnRoutePNames.DEFAULT_PROXY) != null) {
        final HttpHost proxyHost = (HttpHost) httpParams.get(ConnRoutePNames.DEFAULT_PROXY);
        final Boolean socksProxy = (Boolean) httpParams.get("http.route.socks-proxy");
        final ProxyConfig proxyConfig = new ProxyConfig(proxyHost.getHostName(), proxyHost.getPort(),
            socksProxy != null ? socksProxy : false);
        options.setProxyConfig(proxyConfig);
    }

    // disable default gzip compression, as error pages are sent with no compression and htmlunit doesn't negotiate
    new WebConnectionWrapper(webClient) {
        @Override
        public WebResponse getResponse(WebRequest request) throws IOException {
            request.setAdditionalHeader(HttpHeaders.ACCEPT_ENCODING, "identity");
            return super.getResponse(request);
        }
    };

    if (!lazyAuth) {
        try {
            updateOAuthToken();
        } catch (IOException e) {
            throw new IllegalArgumentException(
                String.format("Error authorizing user %s: %s", oAuthParams.getUserName(), e.getMessage()), e);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:45,代码来源:LinkedInOAuthRequestFilter.java


注:本文中的com.gargoylesoftware.htmlunit.ProxyConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。