List of usage examples for org.apache.http.impl.client DecompressingHttpClient DecompressingHttpClient
public DecompressingHttpClient(final HttpClient backend)
From source file:org.elasticsearch.shell.http.ShellHttpClient.java
ShellHttpClient() {
this.httpClient = new DecompressingHttpClient(new DefaultHttpClient());
}
From source file:org.gradle.internal.resource.transport.http.HttpClientHelper.java
public HttpClientHelper(HttpSettings settings) { alwaysUseKeepAliveConnections();//from w w w . j a v a2 s . c o m DefaultHttpClient client = new SystemDefaultHttpClient(); new HttpClientConfigurer(settings).configure(client); this.client = new DecompressingHttpClient(client); }
From source file:com.teamlazerbeez.crm.sf.rest.RestConnectionPoolImpl.java
/** * Create a new pool with a specific idle connection timeout. * * @param idleConnTimeout how long an unused connection must sit idle before it is eligible for removal from the * pool, in seconds *//* w w w .j a v a2s . com*/ public RestConnectionPoolImpl(int idleConnTimeout) { // defaults are too low for these out of the box clientConnManager = new PoolingClientConnectionManager(); clientConnManager.setDefaultMaxPerRoute(20); clientConnManager.setMaxTotal(60); this.httpClient = new DecompressingHttpClient(new DefaultHttpClient(clientConnManager, null)); this.idleConnTimeout = idleConnTimeout; }
From source file:com.twitter.hbc.httpclient.RestartableHttpClient.java
public void setup() { DefaultHttpClient defaultClient = new DefaultHttpClient(new PoolingClientConnectionManager(schemeRegistry), params);//from w ww. j av a 2s. c om auth.setupConnection(defaultClient); if (enableGZip) { underlying.set(new DecompressingHttpClient(defaultClient)); } else { underlying.set(defaultClient); } }
From source file:io.undertow.server.handlers.proxy.AbstractLoadBalancingProxyTestCase.java
@Test public void testLoadShared() throws IOException { final StringBuilder resultString = new StringBuilder(); for (int i = 0; i < 6; ++i) { DecompressingHttpClient client = new DecompressingHttpClient(new TestHttpClient()); try {//w w w . java 2 s.c o m HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/name"); HttpResponse result = client.execute(get); Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode()); resultString.append(HttpClientUtils.readResponse(result)); resultString.append(' '); } finally { client.getConnectionManager().shutdown(); } } Assert.assertTrue(resultString.toString().contains("server1")); Assert.assertTrue(resultString.toString().contains("server2")); }
From source file:org.jasig.portlet.proxy.search.GsaSearchStrategy.java
@Override public List<SearchResult> search(SearchRequest searchQuery, EventRequest request, org.jsoup.nodes.Document ignore) { List<SearchResult> searchResults = new ArrayList<SearchResult>(); String searchBaseURL = this.buildGsaUrl(searchQuery, request); HttpClient client = new DecompressingHttpClient(new DefaultHttpClient()); HttpGet get = new HttpGet(searchBaseURL); try {/*w w w. j a v a 2s. c o m*/ HttpResponse httpResponse = client.execute(get); log.debug("STATUS CODE :: " + httpResponse.getStatusLine().getStatusCode()); InputStream in = httpResponse.getEntity().getContent(); DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = docFactory.newDocumentBuilder(); Document doc = builder.parse(in); log.debug(("GOT InputSource")); XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); Integer maxCount = Integer.parseInt(xPath.evaluate("count(/GSP/RES/R)", doc)); final String[] whitelistRegexes = request.getPreferences().getValues("gsaWhitelistRegex", new String[] {}); log.debug(maxCount + " -- Results"); for (int count = 1; count <= maxCount; count++) { String u = xPath.evaluate("/GSP/RES/R[" + count + "]/U/text()", doc); String t = xPath.evaluate("/GSP/RES/R[" + count + "]/T/text()", doc); String s = xPath.evaluate("/GSP/RES/R[" + count + "]/S/text()", doc); log.debug("title: [" + t + "]"); SearchResult result = new SearchResult(); result.setTitle(t); result.setSummary(s); PortletUrl pUrl = new PortletUrl(); pUrl.setPortletMode(PortletMode.VIEW.toString()); pUrl.setType(PortletUrlType.RENDER); pUrl.setWindowState(WindowState.MAXIMIZED.toString()); PortletUrlParameter param = new PortletUrlParameter(); param.setName("proxy.url"); param.getValue().add(u); pUrl.getParam().add(param); result.setPortletUrl(pUrl); new SearchUtil().updateUrls(u, request, whitelistRegexes); searchResults.add(result); } } catch (IOException ex) { log.error(ex.getMessage(), ex); } catch (XPathExpressionException ex) { log.error(ex.getMessage(), ex); } catch (ParserConfigurationException ex) { log.error(ex.getMessage(), ex); } catch (SAXException ex) { log.error(ex.getMessage(), ex); } return searchResults; }
From source file:at.ac.tuwien.big.testsuite.impl.util.HttpClientProducer.java
@Produces @ApplicationScoped//from ww w .ja v a 2s. co m HttpClient produceHttpClient() { PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); cm.setMaxTotal(100); cm.setDefaultMaxPerRoute(20); DefaultHttpClient client = new DefaultHttpClient(cm); client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() { @Override public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { if (executionCount >= MAX_RETRY_COUNT) { // Do not retry if over max retry count return false; } if (exception instanceof InterruptedIOException) { // Timeout return true; } if (exception instanceof UnknownHostException) { // Unknown host return true; } if (exception instanceof ConnectException) { // Connection refused return true; } if (exception instanceof SSLException) { // SSL handshake exception return true; } HttpRequest request = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST); boolean idempotent = !(request instanceof HttpEntityEnclosingRequest); if (idempotent) { // Retry if the request is considered idempotent return true; } return false; } }); return new DecompressingHttpClient(client); }
From source file:org.jasig.ssp.security.BasicAuthenticationRestTemplate.java
private HttpClient addGzip(HttpClient clientd, Boolean acceptEncodingGzip) { if (acceptEncodingGzip) { return new DecompressingHttpClient(clientd); }//from ww w . j a va2 s .c o m return clientd; }
From source file:org.apache.olingo.client.core.communication.request.AsyncRequestWrapperImpl.java
protected AsyncRequestWrapperImpl(final ODataClient odataClient, final ODataRequest odataRequest) { this.odataRequest = odataRequest; this.odataRequest.setAccept(this.odataRequest.getAccept()); this.odataRequest.setContentType(this.odataRequest.getContentType()); extendHeader(HttpHeader.PREFER, new ODataPreferences().respondAsync()); this.odataClient = odataClient; final HttpMethod method = odataRequest.getMethod(); // target uri this.uri = odataRequest.getURI(); HttpClient _httpClient = odataClient.getConfiguration().getHttpClientFactory().create(method, this.uri); if (odataClient.getConfiguration().isGzipCompression()) { _httpClient = new DecompressingHttpClient(_httpClient); }/* w w w. j a va2 s. com*/ this.httpClient = _httpClient; this.request = odataClient.getConfiguration().getHttpUriRequestFactory().create(method, this.uri); if (request instanceof HttpEntityEnclosingRequestBase) { if (odataRequest instanceof AbstractODataBasicRequest) { AbstractODataBasicRequest<?> br = (AbstractODataBasicRequest<?>) odataRequest; HttpEntityEnclosingRequestBase httpRequest = ((HttpEntityEnclosingRequestBase) request); httpRequest.setEntity(new InputStreamEntity(br.getPayload(), -1)); } } }
From source file:org.apache.olingo.client.core.communication.request.v4.AsyncRequestWrapperImpl.java
protected AsyncRequestWrapperImpl(final ODataClient odataClient, final ODataRequest odataRequest) { this.odataRequest = odataRequest; this.odataRequest.setAccept(this.odataRequest.getAccept()); this.odataRequest.setContentType(this.odataRequest.getContentType()); extendHeader(HeaderName.prefer.toString(), new ODataPreferences(ODataServiceVersion.V40).respondAsync()); this.odataClient = odataClient; final HttpMethod method = odataRequest.getMethod(); // target uri this.uri = odataRequest.getURI(); HttpClient _httpClient = odataClient.getConfiguration().getHttpClientFactory().create(method, this.uri); if (odataClient.getConfiguration().isGzipCompression()) { _httpClient = new DecompressingHttpClient(_httpClient); }//from ww w . ja v a 2 s . c o m this.httpClient = _httpClient; this.request = odataClient.getConfiguration().getHttpUriRequestFactory().create(method, this.uri); }