public interface HttpRequestInitializer
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.
Modifier and Type | Method and Description |
---|---|
void |
initialize(HttpRequest request)
Initializes a request.
|
void initialize(HttpRequest request) throws IOException
request
- HTTP requestIOException
Copyright © 2011–2021 Google. All rights reserved.