/** * Initializes the web client http connection settings. */ private void initWebClientConfig() { m_webClientConfig = new WebClientConfiguration(); if (getParameter("httpClientTimeoutSecs") != null) m_webClientConfig.setTimeoutSecs(Integer.parseInt(getParameter("httpClientTimeoutSecs"))); if (getParameter("httpClientSocketTimeoutSecs") != null) m_webClientConfig.setSockTimeoutSecs(Integer.parseInt(getParameter("httpClientSocketTimeoutSecs"))); if (getParameter("httpClientMaxConnectionsPerHost") != null) m_webClientConfig.setMaxConnPerHost(Integer.parseInt(getParameter("httpClientMaxConnectionsPerHost"))); if (getParameter("httpClientMaxTotalConnections") != null) m_webClientConfig.setMaxTotalConn(Integer.parseInt(getParameter("httpClientMaxTotalConnections"))); if (getParameter("httpClientFollowRedirects") != null) m_webClientConfig.setFollowRedirects(Boolean.parseBoolean(getParameter("httpClientFollowRedirects"))); if (getParameter("httpClientMaxFollowRedirects") != null) m_webClientConfig.setMaxRedirects(Integer.parseInt(getParameter("httpClientMaxFollowRedirects"))); if (getParameter("httpClientUserAgent") != null) m_webClientConfig.setUserAgent(getParameter("httpClientUserAgent")); }
private PoolingClientConnectionManager configureConnectionManager( WebClientConfiguration wconfig){ logger.debug("User-Agent is '" + wconfig.getUserAgent() + "'"); logger.debug("Max total connections is " + wconfig.getMaxTotalConn()); logger.debug("Max connections per host is " + wconfig.getMaxConnPerHost()); logger.debug("Connection timeout is " + wconfig.getTimeoutSecs()); logger.debug("Socket Connection timeout is " + wconfig.getSockTimeoutSecs()); logger.debug("Follow redirects? " + wconfig.getFollowRedirects()); logger.debug("Max number of redirects to follow is " + wconfig.getMaxRedirects()); PoolingClientConnectionManager cManager = new PoolingClientConnectionManager(); cManager.setDefaultMaxPerRoute(wconfig.getMaxConnPerHost()); cManager.setMaxTotal(wconfig.getMaxTotalConn()); //TODO pick the ports up from configuration cManager.getSchemeRegistry().register( new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); cManager.getSchemeRegistry().register( new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); return cManager; }
HttpClient client; setHeaders(request, wconfig.getUserAgent(), ifNoneMatch, ifModifiedSince, range); if (creds != null && creds.getUserName() != null && creds.getUserName().length() > 0) { status != HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { if (wconfig.getFollowRedirects() && 300 <= status && status <= 399) { int count = 1; while (300 <= status && status <= 399 && count <= wconfig.getMaxRedirects()) { if (in.getResponseHeader(HttpHeaders.LOCATION) == null) { in.close(); setHeaders(request, wconfig.getUserAgent(), ifNoneMatch, ifModifiedSince, range); in = new HttpInputStream(client, request); status = in.getStatusCode();
@Test public void testInit() throws ModuleInitializationException { when(mockClientConfig.getMaxConnPerHost()).thenReturn(5); when(mockClientConfig.getMaxTotalConn()).thenReturn(5); testObj.initModule(); }
public WebClient(ProxyConfiguration proxyconfig){ wconfig = new WebClientConfiguration(); proxy = proxyconfig; cManager = configureConnectionManager(wconfig); }
if (m_httpconfig.getUserAgent() == null ) { m_httpconfig.setUserAgent(m_userAgent);
client = new DefaultHttpClient(cManager); client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, wconfig.getTimeoutSecs() * 1000); client.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, wconfig.getSockTimeoutSecs() * 1000);
HttpClient client; setHeaders(request, wconfig.getUserAgent(), ifNoneMatch, ifModifiedSince, range); if (creds != null && creds.getUserName() != null && creds.getUserName().length() > 0) { status != HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { if (wconfig.getFollowRedirects() && 300 <= status && status <= 399) { int count = 1; while (300 <= status && status <= 399 && count <= wconfig.getMaxRedirects()) { if (in.getResponseHeader(HttpHeaders.LOCATION) == null) { in.close(); setHeaders(request, wconfig.getUserAgent(), ifNoneMatch, ifModifiedSince, range); in = new HttpInputStream(client, request); status = in.getStatusCode();
public WebClient(ProxyConfiguration proxyconfig){ wconfig = new WebClientConfiguration(); proxy = proxyconfig; cManager = configureConnectionManager(wconfig); }
if (m_httpconfig.getUserAgent() == null ) { m_httpconfig.setUserAgent(m_userAgent);
client = new DefaultHttpClient(cManager); client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, wconfig.getTimeoutSecs() * 1000); client.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, wconfig.getSockTimeoutSecs() * 1000);
/** * Initializes the web client http connection settings. */ private void initWebClientConfig() { m_webClientConfig = new WebClientConfiguration(); if (getParameter("httpClientTimeoutSecs") != null) m_webClientConfig.setTimeoutSecs(Integer.parseInt(getParameter("httpClientTimeoutSecs"))); if (getParameter("httpClientSocketTimeoutSecs") != null) m_webClientConfig.setSockTimeoutSecs(Integer.parseInt(getParameter("httpClientSocketTimeoutSecs"))); if (getParameter("httpClientMaxConnectionsPerHost") != null) m_webClientConfig.setMaxConnPerHost(Integer.parseInt(getParameter("httpClientMaxConnectionsPerHost"))); if (getParameter("httpClientMaxTotalConnections") != null) m_webClientConfig.setMaxTotalConn(Integer.parseInt(getParameter("httpClientMaxTotalConnections"))); if (getParameter("httpClientFollowRedirects") != null) m_webClientConfig.setFollowRedirects(Boolean.parseBoolean(getParameter("httpClientFollowRedirects"))); if (getParameter("httpClientMaxFollowRedirects") != null) m_webClientConfig.setMaxRedirects(Integer.parseInt(getParameter("httpClientMaxFollowRedirects"))); if (getParameter("httpClientUserAgent") != null) m_webClientConfig.setUserAgent(getParameter("httpClientUserAgent")); }
private PoolingClientConnectionManager configureConnectionManager( WebClientConfiguration wconfig){ logger.debug("User-Agent is '" + wconfig.getUserAgent() + "'"); logger.debug("Max total connections is " + wconfig.getMaxTotalConn()); logger.debug("Max connections per host is " + wconfig.getMaxConnPerHost()); logger.debug("Connection timeout is " + wconfig.getTimeoutSecs()); logger.debug("Socket Connection timeout is " + wconfig.getSockTimeoutSecs()); logger.debug("Follow redirects? " + wconfig.getFollowRedirects()); logger.debug("Max number of redirects to follow is " + wconfig.getMaxRedirects()); PoolingClientConnectionManager cManager = new PoolingClientConnectionManager(); cManager.setDefaultMaxPerRoute(wconfig.getMaxConnPerHost()); cManager.setMaxTotal(wconfig.getMaxTotalConn()); //TODO pick the ports up from configuration cManager.getSchemeRegistry().register( new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); cManager.getSchemeRegistry().register( new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); return cManager; }
private static WebClient getWebClient() { WebClientConfiguration webconfig = new WebClientConfiguration(); initWebClientConfig(webconfig); return new WebClient(webconfig); }
/** * Initializes the web client http connection settings. */ private static void initWebClientConfig(WebClientConfiguration wconf) { if (CONFIG == null) { logger.warn("Web client config was null; cannot configure web client for {}", ServerUtility.class); logger.info("FEDORA_HOME is used to configure web client; was set to {}", Constants.FEDORA_HOME); return; } if (CONFIG.getParameter("httpClientTimeoutSecs") != null) wconf.setTimeoutSecs(Integer.parseInt(CONFIG.getParameter("httpClientTimeoutSecs"))); if (CONFIG.getParameter("httpClientSocketTimeoutSecs") != null) wconf.setSockTimeoutSecs(Integer.parseInt(CONFIG.getParameter("httpClientSocketTimeoutSecs"))); if (CONFIG.getParameter("httpClientMaxConnectionsPerHost") != null) wconf.setMaxConnPerHost(Integer.parseInt(CONFIG.getParameter("httpClientMaxConnectionsPerHost"))); if (CONFIG.getParameter("httpClientMaxTotalConnections") != null) wconf.setMaxTotalConn(Integer.parseInt(CONFIG.getParameter("httpClientMaxTotalConnections"))); if (CONFIG.getParameter("httpClientFollowRedirects") != null) wconf.setFollowRedirects(Boolean.parseBoolean(CONFIG.getParameter("httpClientFollowRedirects"))); if (CONFIG.getParameter("httpClientMaxFollowRedirects") != null) wconf.setMaxRedirects(Integer.parseInt(CONFIG.getParameter("httpClientMaxFollowRedirects"))); if (CONFIG.getParameter("httpClientUserAgent") != null) wconf.setUserAgent(CONFIG.getParameter("httpClientUserAgent")); }
private static WebClient getWebClient() { WebClientConfiguration webconfig = new WebClientConfiguration(); initWebClientConfig(webconfig); return new WebClient(webconfig); }
/** * Initializes the web client http connection settings. */ private static void initWebClientConfig(WebClientConfiguration wconf) { if (CONFIG == null) { logger.warn("Web client config was null; cannot configure web client for {}", ServerUtility.class); logger.info("FEDORA_HOME is used to configure web client; was set to {}", Constants.FEDORA_HOME); return; } if (CONFIG.getParameter("httpClientTimeoutSecs") != null) wconf.setTimeoutSecs(Integer.parseInt(CONFIG.getParameter("httpClientTimeoutSecs"))); if (CONFIG.getParameter("httpClientSocketTimeoutSecs") != null) wconf.setSockTimeoutSecs(Integer.parseInt(CONFIG.getParameter("httpClientSocketTimeoutSecs"))); if (CONFIG.getParameter("httpClientMaxConnectionsPerHost") != null) wconf.setMaxConnPerHost(Integer.parseInt(CONFIG.getParameter("httpClientMaxConnectionsPerHost"))); if (CONFIG.getParameter("httpClientMaxTotalConnections") != null) wconf.setMaxTotalConn(Integer.parseInt(CONFIG.getParameter("httpClientMaxTotalConnections"))); if (CONFIG.getParameter("httpClientFollowRedirects") != null) wconf.setFollowRedirects(Boolean.parseBoolean(CONFIG.getParameter("httpClientFollowRedirects"))); if (CONFIG.getParameter("httpClientMaxFollowRedirects") != null) wconf.setMaxRedirects(Integer.parseInt(CONFIG.getParameter("httpClientMaxFollowRedirects"))); if (CONFIG.getParameter("httpClientUserAgent") != null) wconf.setUserAgent(CONFIG.getParameter("httpClientUserAgent")); }
public WebClient() { wconfig = new WebClientConfiguration(); proxy = new ProxyConfiguration(); cManager = configureConnectionManager(wconfig); }
public WebClient() { wconfig = new WebClientConfiguration(); proxy = new ProxyConfiguration(); cManager = configureConnectionManager(wconfig); }