Java 类org.apache.http.client.protocol.RequestAuthCache 实例源码

项目:lams    文件:DefaultHttpClient.java   
/**
* Create the processor with the following interceptors:
* <ul>
* <li>{@link RequestDefaultHeaders}</li>
* <li>{@link RequestContent}</li>
* <li>{@link RequestTargetHost}</li>
* <li>{@link RequestClientConnControl}</li>
* <li>{@link RequestUserAgent}</li>
* <li>{@link RequestExpectContinue}</li>
* <li>{@link RequestAddCookies}</li>
* <li>{@link ResponseProcessCookies}</li>
* <li>{@link RequestAuthCache}</li>
* <li>{@link RequestTargetAuthentication}</li>
* <li>{@link RequestProxyAuthentication}</li>
* </ul>
* <p>
* @return the processor with the added interceptors.
*/
@Override
protected BasicHttpProcessor createHttpProcessor() {
    BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new RequestDefaultHeaders());
    // Required protocol interceptors
    httpproc.addInterceptor(new RequestContent());
    httpproc.addInterceptor(new RequestTargetHost());
    // Recommended protocol interceptors
    httpproc.addInterceptor(new RequestClientConnControl());
    httpproc.addInterceptor(new RequestUserAgent());
    httpproc.addInterceptor(new RequestExpectContinue());
    // HTTP state management interceptors
    httpproc.addInterceptor(new RequestAddCookies());
    httpproc.addInterceptor(new ResponseProcessCookies());
    // HTTP authentication interceptors
    httpproc.addInterceptor(new RequestAuthCache());
    httpproc.addInterceptor(new RequestTargetAuthentication());
    httpproc.addInterceptor(new RequestProxyAuthentication());
    return httpproc;
}
项目:megabasterd    文件:MiscTools.java   
private static HttpClientBuilder _getApacheKissHttpClientBuilder() {

        return HttpClients.custom()
                .addInterceptorFirst(new RequestDefaultHeaders())
                .addInterceptorFirst(new RequestContent())
                .addInterceptorFirst(new RequestTargetHost())
                .addInterceptorFirst(new RequestClientConnControl())
                .addInterceptorFirst(new RequestAddCookies())
                .addInterceptorFirst(new ResponseProcessCookies())
                .addInterceptorFirst(new RequestAuthCache())
                .addInterceptorLast(new HttpRequestInterceptor() {

                    @Override
                    public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {

                        if (request.containsHeader("User-Agent")) {

                            request.removeHeaders("User-Agent");

                        }

                        if (request.containsHeader("Custom-User-Agent")) {

                            request.addHeader("User-Agent", request.getFirstHeader("Custom-User-Agent").getValue());

                            request.removeHeaders("Custom-User-Agent");
                        }
                    }

                });
    }
项目:purecloud-iot    文件:DefaultHttpClient.java   
/**
* Create the processor with the following interceptors:
* <ul>
* <li>{@link RequestDefaultHeaders}</li>
* <li>{@link RequestContent}</li>
* <li>{@link RequestTargetHost}</li>
* <li>{@link RequestClientConnControl}</li>
* <li>{@link RequestUserAgent}</li>
* <li>{@link RequestExpectContinue}</li>
* <li>{@link RequestAddCookies}</li>
* <li>{@link ResponseProcessCookies}</li>
* <li>{@link RequestAuthCache}</li>
* <li>{@link RequestTargetAuthentication}</li>
* <li>{@link RequestProxyAuthentication}</li>
* </ul>
* <p>
* @return the processor with the added interceptors.
*/
@Override
protected BasicHttpProcessor createHttpProcessor() {
    final BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new RequestDefaultHeaders());
    // Required protocol interceptors
    httpproc.addInterceptor(new RequestContent());
    httpproc.addInterceptor(new RequestTargetHost());
    // Recommended protocol interceptors
    httpproc.addInterceptor(new RequestClientConnControl());
    httpproc.addInterceptor(new RequestUserAgent());
    httpproc.addInterceptor(new RequestExpectContinue());
    // HTTP state management interceptors
    httpproc.addInterceptor(new RequestAddCookies());
    httpproc.addInterceptor(new ResponseProcessCookies());
    // HTTP authentication interceptors
    httpproc.addInterceptor(new RequestAuthCache());
    httpproc.addInterceptor(new RequestTargetAuthentication());
    httpproc.addInterceptor(new RequestProxyAuthentication());
    return httpproc;
}
项目:taxii-log-adapter    文件:BasicAuthHttpRequestFactoryTest.java   
@Before
public void setUp() throws Exception {
    httpClient = HttpClients.createDefault();
    credentialsProvider = Mockito.mock(CredentialsProvider.class);
    connSettings = TaxiiServiceSettingsFactory.createDefaults();
    proxySettings = new ProxySettings();
    credentialsProvider = Mockito.mock(CredentialsProvider.class);
    factory = new BasicAuthHttpRequestFactory(httpClient, connSettings, proxySettings, credentialsProvider);
    MockitoAnnotations.initMocks(this);
    when(mockAppender.getName()).thenReturn("MOCK");
    Logger authCacheLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(RequestAuthCache.class.getCanonicalName());
    authCacheLogger.setLevel(Level.DEBUG);
    authCacheLogger.addAppender(mockAppender);
}