Interface HttpRequestInitializer (1.45.1)

public interface HttpRequestInitializer

HTTP request initializer.

For example, this might be used to disable request timeouts:

public class DisableTimeout implements HttpRequestInitializer { public void initialize(HttpRequest request) { request.setConnectTimeout(0); request.setReadTimeout(0); } }

Sample usage with a request factory:

public static HttpRequestFactory createRequestFactory(HttpTransport transport) { return transport.createRequestFactory(new DisableTimeout()); }

More complex usage example:

public static HttpRequestFactory createRequestFactory2(HttpTransport transport) { final DisableTimeout disableTimeout = new DisableTimeout(); return transport.createRequestFactory(new HttpRequestInitializer() { public void initialize(HttpRequest request) { disableTimeout.initialize(request); } }); }

Implementations should normally be thread-safe.

Methods

initialize(HttpRequest request)

public abstract void initialize(HttpRequest request)

Initializes a request.

Parameter
Name Description
request HttpRequest

HTTP request

Exceptions
Type Description
IOException