use of org.apache.http.HttpHost in project tdi-studio-se by Talend.
the class paloconnection method initConnection.
private void initConnection() {
pingPaloServer();
paloTargetHost = new HttpHost(strServer, Integer.valueOf(strPort), "http");
SchemeRegistry supportedSchemes = new SchemeRegistry();
supportedSchemes.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Integer.valueOf(strPort)));
// prepare parameters
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpProtocolParams.setUseExpectContinue(params, true);
ClientConnectionManager connMgr = new ThreadSafeClientConnManager(params, supportedSchemes);
paloHttpClient = new DefaultHttpClient(connMgr, params);
}
use of org.apache.http.HttpHost in project tdi-studio-se by Talend.
the class DynamicsCRMClient method setHttpclientProxy.
/**
* Setup proxy for httpClient
*/
private void setHttpclientProxy(DefaultHttpClient httpClient) {
Proxy proxy = getProxy();
String proxyUser = System.getProperty("https.proxyUser");
String proxyPwd = System.getProperty("https.proxyPassword");
// set by other components like tSetProxy
if (proxy != null) {
final HttpHost httpHost = new HttpHost(((InetSocketAddress) proxy.address()).getHostName(), ((InetSocketAddress) proxy.address()).getPort());
// Sets usage of HTTP proxy
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, httpHost);
// TODO Because the proxy of get accesToken can't support authentication. remove this ?
if (proxyUser != null && proxyPwd != null) {
httpClient.getCredentialsProvider().setCredentials(new AuthScope(httpHost), new UsernamePasswordCredentials(proxyUser, proxyPwd));
}
}
}
use of org.apache.http.HttpHost in project orientdb by orientechnologies.
the class BaseHttpTest method exec.
protected BaseHttpTest exec() throws IOException {
final HttpHost targetHost = new HttpHost(getHost(), getPort(), getProtocol());
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(targetHost), new UsernamePasswordCredentials(getUserName(), getUserPassword()));
// Create AuthCache instance
AuthCache authCache = new BasicAuthCache();
// Generate BASIC scheme object and add it to the local auth cache
BasicScheme basicAuth = new BasicScheme();
authCache.put(targetHost, basicAuth);
// Add AuthCache to the execution context
HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credsProvider);
context.setAuthCache(authCache);
if (keepAlive != null)
request.addHeader("Connection", keepAlive ? "Keep-Alive" : "Close");
if (payload != null && request instanceof HttpEntityEnclosingRequestBase)
((HttpEntityEnclosingRequestBase) request).setEntity(payload);
final CloseableHttpClient httpClient = HttpClients.createDefault();
// DefaultHttpMethodRetryHandler retryhandler = new DefaultHttpMethodRetryHandler(retry, false);
// context.setAttribute(HttpMethodParams.RETRY_HANDLER, retryhandler);
response = httpClient.execute(targetHost, request, context);
return this;
}
use of org.apache.http.HttpHost in project Libraries-for-Android-Developers by eoecn.
the class AsyncHttpClient method setProxy.
/**
* Sets the Proxy by it's hostname and port
*
* @param hostname the hostname (IP or DNS name)
* @param port the port number. -1 indicates the scheme default port.
*/
public void setProxy(String hostname, int port) {
final HttpHost proxy = new HttpHost(hostname, port);
final HttpParams httpParams = this.httpClient.getParams();
httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
use of org.apache.http.HttpHost in project SeaStar by 13120241790.
the class SyncHttpClient method setProxy.
/**
* Sets the Proxy by it's hostname and port
*
* @param hostname
* the hostname (IP or DNS name)
* @param port
* the port number. -1 indicates the scheme default port.
*/
public void setProxy(String hostname, int port) {
final HttpHost proxy = new HttpHost(hostname, port);
final HttpParams httpParams = this.httpClient.getParams();
httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
Aggregations