use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionTest method assertRequestConfig.
private static void assertRequestConfig(DefaultConnection connection, int connectTimeout, int socketTimeout) {
RequestConfig requestConfig = connection.requestConfig;
Assert.assertEquals(connectTimeout, requestConfig.getConnectTimeout());
Assert.assertEquals(socketTimeout, requestConfig.getSocketTimeout());
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project ecf by eclipse.
the class RestClientService method setupHttpMethod.
protected void setupHttpMethod(HttpRequestBase httpMethod, IRemoteCall call, IRemoteCallable callable) {
RequestConfig defaultRequestConfig = httpMethod.getConfig();
RequestConfig.Builder updatedRequestConfigBuilder = (defaultRequestConfig == null) ? RequestConfig.custom() : RequestConfig.copy(defaultRequestConfig);
// setup to allow regular and circular redirects
updatedRequestConfigBuilder.setCircularRedirectsAllowed(true);
updatedRequestConfigBuilder.setRedirectsEnabled(true);
int sTimeout = socketTimeout;
int scTimeout = connectTimeout;
int scrTimeout = connectRequestTimeout;
long callTimeout = call.getTimeout();
if (callTimeout == IRemoteCall.DEFAULT_TIMEOUT)
callTimeout = callable.getDefaultTimeout();
if (callTimeout != IRemoteCall.DEFAULT_TIMEOUT) {
sTimeout = scTimeout = scrTimeout = new Long(callTimeout).intValue();
}
updatedRequestConfigBuilder.setSocketTimeout(sTimeout);
updatedRequestConfigBuilder.setConnectTimeout(scTimeout);
updatedRequestConfigBuilder.setConnectionRequestTimeout(scrTimeout);
httpMethod.setConfig(updatedRequestConfigBuilder.build());
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project ma-core-public by infiniteautomation.
the class StoreLatestSnapshotTest method getHttpClient.
protected HttpClient getHttpClient(int timeout) {
// Create global request configuration
RequestConfig defaultRequestConfig = RequestConfig.custom().setExpectContinueEnabled(true).setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.DIGEST)).setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC)).setSocketTimeout(timeout).setConnectTimeout(timeout).build();
// Create an HttpClient with the given custom dependencies and configuration.
CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(defaultRequestConfig).build();
return httpclient;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project ma-core-public by infiniteautomation.
the class Common method getHttpClient.
public static HttpClient getHttpClient(int timeout) {
// Create global request configuration
RequestConfig defaultRequestConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.DEFAULT).setExpectContinueEnabled(true).setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.DIGEST)).setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC)).setSocketTimeout(timeout).setConnectTimeout(timeout).build();
if (SystemSettingsDao.getBooleanValue(SystemSettingsDao.HTTP_CLIENT_USE_PROXY)) {
String proxyHost = SystemSettingsDao.getValue(SystemSettingsDao.HTTP_CLIENT_PROXY_SERVER);
int proxyPort = SystemSettingsDao.getIntValue(SystemSettingsDao.HTTP_CLIENT_PROXY_PORT);
String username = SystemSettingsDao.getValue(SystemSettingsDao.HTTP_CLIENT_PROXY_USERNAME, "");
String password = SystemSettingsDao.getValue(SystemSettingsDao.HTTP_CLIENT_PROXY_PASSWORD, "");
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(proxyHost, proxyPort), new UsernamePasswordCredentials(username, password));
// Create an HttpClient with the given custom dependencies and configuration.
CloseableHttpClient httpclient = HttpClients.custom().setProxy(new HttpHost(proxyHost, proxyPort)).setDefaultRequestConfig(defaultRequestConfig).setDefaultCredentialsProvider(credentialsProvider).build();
return httpclient;
} else {
// Create an HttpClient with the given custom dependencies and configuration.
CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(defaultRequestConfig).build();
return httpclient;
}
// LEGACY CODE LEFT HERE UNTIL Testing of above code is confirmed as working
// DefaultHttpClient client = new DefaultHttpClient();
// client.getParams().setParameter("http.socket.timeout", timeout);
// client.getParams().setParameter("http.connection.timeout", timeout);
// client.getParams().setParameter("http.connection-manager.timeout", timeout);
// client.getParams().setParameter("http.protocol.head-body-timeout", timeout);
//
// if (SystemSettingsDao.getBooleanValue(SystemSettingsDao.HTTP_CLIENT_USE_PROXY)) {
// String proxyHost = SystemSettingsDao.getValue(SystemSettingsDao.HTTP_CLIENT_PROXY_SERVER);
// int proxyPort = SystemSettingsDao.getIntValue(SystemSettingsDao.HTTP_CLIENT_PROXY_PORT);
// String username = SystemSettingsDao.getValue(SystemSettingsDao.HTTP_CLIENT_PROXY_USERNAME, "");
// String password = SystemSettingsDao.getValue(SystemSettingsDao.HTTP_CLIENT_PROXY_PASSWORD, "");
//
// client.getCredentialsProvider().setCredentials(new AuthScope(proxyHost, proxyPort),
// new UsernamePasswordCredentials(username, password));
//
// }
//
// return client;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project neo-java by coranos.
the class TestRpcServerUtil method getCityOfZionResponse.
/**
* @param input
* the input to use.
* @param method
* the method to call.
* @return the reseponse.
*/
public static String getCityOfZionResponse(final String input, final String method) {
try {
final String url = CityOfZionUtil.MAINNET_API + method + input;
LOG.debug("url:{}", url);
final HttpGet httpRequest = new HttpGet(url);
final RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(TIMEOUT_MILLIS).setConnectTimeout(TIMEOUT_MILLIS).setConnectionRequestTimeout(TIMEOUT_MILLIS).build();
httpRequest.setConfig(requestConfig);
final CloseableHttpClient client = HttpClients.createDefault();
final String responseStr;
try {
final CloseableHttpResponse response = client.execute(httpRequest);
logDebugStatus(response);
final HttpEntity entity = response.getEntity();
responseStr = EntityUtils.toString(entity);
} catch (final ConnectTimeoutException | SocketTimeoutException | NoHttpResponseException | SocketException e) {
throw new RuntimeException(CONNECTION_EXCEPTION, e);
}
final JSONObject responseJson = new JSONObject(responseStr);
final String actualStr = responseJson.toString(2);
return actualStr;
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
Aggregations