Interface HttpExecuteInterceptor (1.45.0)

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.setInterceptor(signer); } }); }

More complex usage example:

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

Implementations should normally be thread-safe.

Methods

intercept(HttpRequest request)

public abstract void intercept(HttpRequest request)

Invoked at the start of HttpRequest#execute() before executing the HTTP request.

Parameter
Name Description
request HttpRequest
Exceptions
Type Description
IOException