public interface HttpExecuteInterceptor
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.
Modifier and Type | Method and Description |
---|---|
void |
intercept(HttpRequest request)
Invoked at the start of
HttpRequest.execute() before executing the HTTP request. |
void intercept(HttpRequest request) throws IOException
HttpRequest.execute()
before executing the HTTP request.IOException
Copyright © 2011–2020 Google. All rights reserved.