com.google.api.client.http
Interface HttpExecuteInterceptor


public interface HttpExecuteInterceptor

HTTP request execute interceptor to intercept the start of HttpRequest.execute() before executing the HTTP request.

For example, this might be used to sign a request for OAuth:

  public class OAuthSigner implements HttpExecuteInterceptor {
    public void intercept(HttpRequest request) throws IOException {
      // sign request...
    }
  }
 

Sample usage with a request factory:

  public static HttpRequestFactory createRequestFactory(HttpTransport transport) {
    final OAuthSigner signer = new OAuthSigner(...);
    return transport.createRequestFactory(new HttpRequestInitializer() {
      public void initialize(HttpRequest request) {
        request.interceptor = signer;
      }
    });
  }
 

If you have a custom request execute interceptor, use this more complex example:

  public static HttpRequestFactory createRequestFactory(HttpTransport transport) {
    final OAuthSigner signer = new OAuthSigner(...);
    return transport.createRequestFactory(new HttpRequestInitializer() {
      public void initialize(HttpRequest request) {
        request.interceptor = new HttpExecuteInterceptor() {
          public void intercept(HttpRequest request) throws IOException {
            signer.intercept(request);
          }
        };
      }
    });
  }
 

Implementations should normally be thread-safe.

Since:
1.0
Author:
Yaniv Inbar

Method Summary
 void intercept(HttpRequest request)
          Invoked at the start of HttpRequest.execute() before executing the HTTP request.
 

Method Detail

intercept

void intercept(HttpRequest request)
               throws IOException
Invoked at the start of HttpRequest.execute() before executing the HTTP request.

Throws:
IOException


Copyright © 2011 Google. All Rights Reserved.