use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project intellij-community by JetBrains.
the class EduAdaptiveStepicConnector method setTimeout.
private static void setTimeout(HttpGet request) {
final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_TIMEOUT).setConnectTimeout(CONNECTION_TIMEOUT).setSocketTimeout(CONNECTION_TIMEOUT).build();
request.setConfig(requestConfig);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project mastering-java by Kingminghuang.
the class HttpClientCrawler method testTimeout.
private static void testTimeout() throws IOException {
int timeout = 15;
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(timeout * 1000).setSocketTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000).setProxy(new HttpHost(DEFAULT_PROXY, DEFAULT_PORT, DEFAULT_SCHEMA)).build();
config(requestConfig);
HttpGet httpGet = new HttpGet("http://www.google.com:80");
HttpResponse response = client.execute(httpGet);
System.out.println(response.getStatusLine().getStatusCode());
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project mastering-java by Kingminghuang.
the class HttpClientCrawler method testHardTimeout.
private static void testHardTimeout() throws IOException {
int hardTimeout = 15;
RequestConfig requestConfig = RequestConfig.custom().setProxy(new HttpHost(DEFAULT_PROXY, DEFAULT_PORT, DEFAULT_SCHEMA)).build();
config(requestConfig);
HttpGet httpGet = new HttpGet(EXAMPLE_URL);
TimerTask task = new TimerTask() {
@Override
public void run() {
if (httpGet != null) {
httpGet.abort();
}
}
};
new Timer(true).schedule(task, hardTimeout * 1000);
HttpResponse response = client.execute(httpGet);
System.out.println(response.getStatusLine().getStatusCode());
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project mastering-java by Kingminghuang.
the class HttpClientCrawler method testStatusCode.
private static void testStatusCode() throws IOException {
RequestConfig requestConfig = RequestConfig.custom().setProxy(new HttpHost(DEFAULT_PROXY, DEFAULT_PORT, DEFAULT_SCHEMA)).build();
config(requestConfig);
HttpGet httpGet = new HttpGet(EXAMPLE_URL);
CloseableHttpResponse response = client.execute(httpGet);
int statusCode = response.getStatusLine().getStatusCode();
System.out.println(statusCode == HttpStatus.SC_OK);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project libresonic by Libresonic.
the class LyricsService method executeGetRequest.
private String executeGetRequest(String url) throws IOException {
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(15000).setSocketTimeout(15000).build();
HttpGet method = new HttpGet(url);
method.setConfig(requestConfig);
try (CloseableHttpClient client = HttpClients.createDefault()) {
ResponseHandler<String> responseHandler = new BasicResponseHandler();
return client.execute(method, responseHandler);
}
}
Aggregations