Java Code Examples for org.apache.http.client.protocol.HttpClientContext#getAttribute()

The following examples show how to use org.apache.http.client.protocol.HttpClientContext#getAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProxyFeedBackClientExecChain.java    From vscrawler with Apache License 2.0 6 votes vote down vote up
@Override
public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request, HttpClientContext clientContext,
        HttpExecutionAware execAware) throws IOException, HttpException {
    Proxy proxy = (Proxy) clientContext.getAttribute(VSCrawlerConstant.VSCRAWLER_AVPROXY_KEY);
    if (proxy != null) {
        proxy.recordUsage();
    }
    try {
        return delegate.execute(route, request, clientContext, execAware);
    } catch (IOException ioe) {
        if (proxy != null) {
            proxy.recordFailed();
        }
        throw ioe;
    }
}
 
Example 2
Source File: CallbackProxyAuthenticationStrategy.java    From cyberduck with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void authSucceeded(final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final Credentials credentials = clientContext.getAttribute(PROXY_CREDENTIALS_INPUT_ID, Credentials.class);
    if(null != credentials) {
        clientContext.removeAttribute(PROXY_CREDENTIALS_INPUT_ID);
        if(log.isInfoEnabled()) {
            log.info(String.format("Save passphrase for proxy %s", authhost));
        }
        keychain.addCredentials(authhost.toURI(), credentials.getUsername(), credentials.getPassword());
    }
    super.authSucceeded(authhost, authScheme, context);
}
 
Example 3
Source File: HttpContextRetryCounter.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
public void setRetryCount(HttpClientContext context, int value) {
  RetryCount count = context.getAttribute(attributeName, RetryCount.class);

  if (count == null) {
    count = new RetryCount();
    context.setAttribute(attributeName, count);
  }

  count.value = value;
}
 
Example 4
Source File: YoutubeIpRotatorFilter.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
private void setRetryCount(HttpClientContext context, int value) {
  RetryCount count = context.getAttribute(RETRY_COUNT_ATTRIBUTE, RetryCount.class);

  if (count == null) {
    count = new RetryCount();
    context.setAttribute(RETRY_COUNT_ATTRIBUTE, count);
  }

  count.value = value;
}
 
Example 5
Source File: SoundCloudClientIdTracker.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
public boolean isIdFetchContext(HttpClientContext context) {
  return context.getAttribute(ID_FETCH_CONTEXT_ATTRIBUTE) == Boolean.TRUE;
}
 
Example 6
Source File: HttpContextRetryCounter.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
public int getRetryCount(HttpClientContext context) {
  RetryCount count = context.getAttribute(attributeName, RetryCount.class);
  return count != null ? count.value : 0;
}
 
Example 7
Source File: AbstractRoutePlanner.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
public final InetAddress getLastAddress(final HttpClientContext context) {
  return context.getAttribute(CHOSEN_IP_ATTRIBUTE, InetAddress.class);
}
 
Example 8
Source File: YoutubeIpRotatorFilter.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
private int getRetryCount(HttpClientContext context) {
  RetryCount count = context.getAttribute(RETRY_COUNT_ATTRIBUTE, RetryCount.class);
  return count != null ? count.value : 0;
}