org.apache.http.client.protocol.HttpClientContext#getAttribute ( )源码实例Demo

下面列出了org.apache.http.client.protocol.HttpClientContext#getAttribute ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: vscrawler   文件: ProxyFeedBackClientExecChain.java
@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;
    }
}
 
@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);
}
 
源代码3 项目: lavaplayer   文件: HttpContextRetryCounter.java
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;
}
 
源代码4 项目: lavaplayer   文件: YoutubeIpRotatorFilter.java
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;
}
 
源代码5 项目: lavaplayer   文件: SoundCloudClientIdTracker.java
public boolean isIdFetchContext(HttpClientContext context) {
  return context.getAttribute(ID_FETCH_CONTEXT_ATTRIBUTE) == Boolean.TRUE;
}
 
源代码6 项目: lavaplayer   文件: HttpContextRetryCounter.java
public int getRetryCount(HttpClientContext context) {
  RetryCount count = context.getAttribute(attributeName, RetryCount.class);
  return count != null ? count.value : 0;
}
 
源代码7 项目: lavaplayer   文件: AbstractRoutePlanner.java
public final InetAddress getLastAddress(final HttpClientContext context) {
  return context.getAttribute(CHOSEN_IP_ATTRIBUTE, InetAddress.class);
}
 
源代码8 项目: lavaplayer   文件: YoutubeIpRotatorFilter.java
private int getRetryCount(HttpClientContext context) {
  RetryCount count = context.getAttribute(RETRY_COUNT_ATTRIBUTE, RetryCount.class);
  return count != null ? count.value : 0;
}