/** * Sets the virtual host name. * * @param hostname The host name */ public void setVirtualHost(final String hostname) { setParameter(HttpMethodParams.VIRTUAL_HOST, hostname); }
/** * Sets the virtual host name. * * @param hostname The host name */ public void setVirtualHost(final String hostname) { setParameter(HttpMethodParams.VIRTUAL_HOST, hostname); }
/** * Sets the virtual host name. * * @param hostname The host name */ public void setVirtualHost(final String hostname) { setParameter(HttpMethodParams.VIRTUAL_HOST, hostname); }
/** * Sets the virtual host name. * * @param hostname The host name */ public void setVirtualHost(final String hostname) { setParameter(HttpMethodParams.VIRTUAL_HOST, hostname); }
/** * Sets the virtual host name. * * @param hostname The host name */ public void setVirtualHost(final String hostname) { setParameter(HttpMethodParams.VIRTUAL_HOST, hostname); }
private void ensureClientInitialized() { if(configuration == null) throw new IllegalStateException("client must be initialized first."); if (client != null) return; client = new HttpClient(manager); HttpConnectionManager connectionManager = client.getHttpConnectionManager(); HttpConnectionManagerParams params = connectionManager.getParams(); params.setConnectionTimeout(configuration.getDefaultTimeout()); params.setSoTimeout(configuration.getDefaultTimeout()); params.setMaxTotalConnections(configuration.getMaxConnections()); HostConfiguration hostConf = client.getHostConfiguration(); List<Header> headers = new ArrayList<Header>(); headers.add(new Header("User-Agent", configuration.getUserAgent())); if (configuration.getAcceptHeader() != null) { headers.add(new Header("Accept", configuration.getAcceptHeader())); } headers.add(new Header("Accept-Language", "en-us,en-gb,en,*;q=0.3")); //TODO: this must become parametric. headers.add(new Header("Accept-Charset", "utf-8,iso-8859-1;q=0.7,*;q=0.5")); // headers.add(new Header("Accept-Encoding", "x-gzip, gzip")); hostConf.getParams().setParameter("http.default-headers", headers); }
protected void configureHttpClient() throws IOException, GeneralSecurityException { httpClient.getParams().setAuthenticationPreemptive(isAuthenticationPreemptive()); initCredentials(); initSocketFactory(); initProtocolIfNeeded(); if (httpConnectionManager != null) { httpClient.setHttpConnectionManager(httpConnectionManager); } List<Header> headers = getDefaultHeaders(); httpClient.getHostConfiguration().getParams().setParameter(HostParams.DEFAULT_HEADERS, headers); httpClient.getParams().setParameter(HttpClientParams.USER_AGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/11.04 Chromium/18.0.1025.151 Chrome/18.0.1025.151 Safari/535.19"); httpClient.getParams().setParameter(HttpClientParams.HTTP_CONTENT_CHARSET, "UTF-8"); httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); httpClient.getParams().setConnectionManagerTimeout(connectionManagerTimeout); httpClient.getParams().setSoTimeout(soTimeout); if (connectionTimeout >= 0) { httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout); } }
client.getHostConfiguration().getParams().setParameter("http.default-headers", headers); for (Header hd : headers) { log(hd.getName() + ": " + hd.getValue());
headers.add(new Header("API-RemoteIP", ipaddr.getHostAddress())); client.getHostConfiguration().getParams() .setParameter("http.default-headers", headers); for (Header hd : headers) { log(hd.getName() + ": " + hd.getValue());
httpConfiguration.getParams().setParameter( CustomMultiThreadedHttpConnectionManager.NON_PROXY_HOSTS_PATTERNS_KEY, nonProxyHostPatterns );