Interface HttpRequestInitializer (1.42.3)

Stay organized with collections Save and categorize content based on your preferences.
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
NameDescription
requestHttpRequest

HTTP request

Exceptions
TypeDescription
IOException