Examples of addRequestInterceptor()


Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

        // execution context
        BasicScheme basicAuth = new BasicScheme();
        localcontext.setAttribute("preemptive-auth", basicAuth);
       
        // Add as the first request interceptor
        httpclient.addRequestInterceptor(new PreemptiveAuth(), 0);
       
        HttpHost targetHost = new HttpHost("localhost", 80, "http");

        HttpGet httpget = new HttpGet("/");
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

public class ClientGZipContentCompression {

    public final static void main(String[] args) throws Exception {
        DefaultHttpClient httpclient = new DefaultHttpClient();

        httpclient.addRequestInterceptor(new HttpRequestInterceptor() {
          
            public void process(
                    final HttpRequest request,
                    final HttpContext context) throws HttpException, IOException {
                if (!request.containsHeader("Accept-Encoding")) {
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

        // Suppose we already know the expected nonce value
        digestAuth.overrideParamter("nonce", "whatever");       
        localcontext.setAttribute("preemptive-auth", digestAuth);
       
        // Add as the first request interceptor
        httpclient.addRequestInterceptor(new PreemptiveAuth(), 0);
        // Add as the last response interceptor
        httpclient.addResponseInterceptor(new PersistentDigest());
       
        HttpHost targetHost = new HttpHost("localhost", 80, "http");
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

    // try resending the request once
    client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(1, true));

    // Add hooks for gzip/deflate
    client.addRequestInterceptor(new HttpRequestInterceptor() {
      public void process(
          final org.apache.http.HttpRequest request,
          final HttpContext context) throws HttpException, IOException {
        if (!request.containsHeader("Accept-Encoding")) {
          request.addHeader("Accept-Encoding", "gzip, deflate");
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

public class ClientGZipContentCompression {

    public final static void main(String[] args) throws Exception {
        DefaultHttpClient httpclient = new DefaultHttpClient();

        httpclient.addRequestInterceptor(new HttpRequestInterceptor() {
          
            public void process(
                    final HttpRequest request,
                    final HttpContext context) throws HttpException, IOException {
                if (!request.containsHeader("Accept-Encoding")) {
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

    // try resending the request once
    client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(1, true));

    // Add hooks for gzip/deflate
    client.addRequestInterceptor(new HttpRequestInterceptor() {
      public void process(
          final org.apache.http.HttpRequest request,
          final HttpContext context) throws HttpException, IOException {
        if (!request.containsHeader("Accept-Encoding")) {
          request.addHeader("Accept-Encoding", "gzip, deflate");
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

        for (Cookie cookie : cookieList) {
            httpclient.getCookieStore().addCookie(cookie);
        }*/

        try {
            httpclient.addRequestInterceptor(new HttpRequestInterceptor() {

                public void process(
                        final HttpRequest request,
                        final HttpContext context) throws HttpException, IOException {
                    if (!request.containsHeader("Accept-Encoding")) {
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

        EntityUtils.consume( response.getEntity() );

        // Simple interceptor set as first interceptor in the protocol chain
        HttpRequestInterceptor preemptiveAuth = new BasicAuthRequestInterceptor();
        client.addRequestInterceptor( preemptiveAuth, 0 );

        // Set credentials
        UsernamePasswordCredentials creds = new UsernamePasswordCredentials( "foo", "bar" );
        client.getCredentialsProvider().setCredentials( AuthScope.ANY, creds );
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

    {
      // Append to existing file
      final Map<String, String> header = Collections.singletonMap(HttpHeaders.CONTENT_RANGE,
          "bytes " + 2 + "-" + 3 + "/" + 4);

      client.addRequestInterceptor(new HttpRequestInterceptor()
      {
        public void process(final HttpRequest r, final HttpContext context) throws HttpException, IOException
        {
          assertNotNull(r.getHeaders(HttpHeaders.CONTENT_RANGE));
          assertEquals(1, r.getHeaders(HttpHeaders.CONTENT_RANGE).length);
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()

  @Test
  public void testBasicPreemptiveAuthHeader() throws Exception
  {
    final DefaultHttpClient client = new DefaultHttpClient();
    client.addRequestInterceptor(new HttpRequestInterceptor()
    {
      public void process(final HttpRequest r, final HttpContext context) throws HttpException, IOException
      {
        assertNotNull(r.getHeaders(HttpHeaders.AUTHORIZATION));
        assertEquals(1, r.getHeaders(HttpHeaders.AUTHORIZATION).length);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.