List of usage examples for org.apache.http.impl.client AbstractHttpClient addRequestInterceptor
public synchronized void addRequestInterceptor(final HttpRequestInterceptor itcp)
From source file:com.plugtree.solrmeter.model.SolrServerRegistry.java
private static void setAuthentication(HttpSolrServer httpServer) { String user = SolrMeterConfiguration.getProperty("solr.server.configuration.httpAuthUser"); String pass = SolrMeterConfiguration.getProperty("solr.server.configuration.httpAuthPass"); if (user != null && !user.isEmpty() && pass != null && !pass.isEmpty()) { AbstractHttpClient client = (AbstractHttpClient) httpServer.getHttpClient(); client.addRequestInterceptor(new PreEmptiveBasicAuthenticator(user, pass)); }/*from w w w . j a v a2 s .c o m*/ }
From source file:ch.cyberduck.core.http.HttpSession.java
protected void configure(final AbstractHttpClient client) { client.addRequestInterceptor(new HttpRequestInterceptor() { @Override/*from w w w . j a v a2 s .c o m*/ public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { log(true, request.getRequestLine().toString()); for (Header header : request.getAllHeaders()) { log(true, header.toString()); } domain = ((HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST)).getHostName(); } }); client.addResponseInterceptor(new HttpResponseInterceptor() { @Override public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException { log(false, response.getStatusLine().toString()); for (Header header : response.getAllHeaders()) { log(false, header.toString()); } } }); if (Preferences.instance().getBoolean("http.compression.enable")) { client.addRequestInterceptor(new RequestAcceptEncoding()); client.addResponseInterceptor(new ResponseContentEncoding()); } }
From source file:com.jayway.restassured.internal.http.ContentEncodingRegistry.java
/** * Add the request and response interceptors to the {@link HttpClient}, * which will provide transparent decoding of the given content-encoding * types. This method is called by HTTPBuilder and probably should not need * be modified by sub-classes.// w ww. ja v a 2 s . c o m * * @param client client on which to set the request and response interceptors * @param encodings encoding name (either a {@link ContentEncoding.Type} or * a <code>content-encoding</code> string. */ void setInterceptors(final AbstractHttpClient client, Object... encodings) { // remove any encoding interceptors that are already set client.removeRequestInterceptorByClass(ContentEncoding.RequestInterceptor.class); client.removeResponseInterceptorByClass(ContentEncoding.ResponseInterceptor.class); for (Object encName : encodings) { ContentEncoding enc = availableEncoders.get(encName.toString()); if (enc == null) continue; client.addRequestInterceptor(enc.getRequestInterceptor()); client.addResponseInterceptor(enc.getResponseInterceptor()); } }