def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
}
public class ApacheHttpBuilder extends HttpBuilder
HttpBuilder implementation based on the Apache HttpClient library.
Generally, this class should not be used directly, the preferred method of instantiation is via one of the two static configure() methods of this
class or using one of the configure methods of HttpBuilder with a factory function for this builder.
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
ApacheHttpBuilder.ApacheToServer  | 
HttpBuilder.ResponseHandlerFunction| Constructor and Description | 
|---|
ApacheHttpBuilder(HttpObjectConfig config)
Creates a new  
HttpBuilder based on the Apache HTTP client. | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
close()  | 
static HttpBuilder | 
configure(Closure closure)
Creates an  
HttpBuilder using the ApacheHttpBuilder factory instance configured with the provided configuration closure. | 
static HttpBuilder | 
configure(java.util.function.Consumer<HttpObjectConfig> configuration)
Creates an  
HttpBuilder using the ApacheHttpBuilder factory instance configured with the provided configuration function. | 
protected java.lang.Object | 
doDelete(ChainedHttpConfig requestConfig)  | 
protected java.lang.Object | 
doGet(ChainedHttpConfig requestConfig)  | 
protected java.lang.Object | 
doHead(ChainedHttpConfig requestConfig)  | 
protected java.lang.Object | 
doOptions(ChainedHttpConfig config)  | 
protected java.lang.Object | 
doPatch(ChainedHttpConfig requestConfig)  | 
protected java.lang.Object | 
doPost(ChainedHttpConfig requestConfig)  | 
protected java.lang.Object | 
doPut(ChainedHttpConfig requestConfig)  | 
protected java.lang.Object | 
doTrace(ChainedHttpConfig config)  | 
java.lang.Object | 
getClientImplementation()
Retrieves the internal client implementation as an  
HttpClient instance. | 
java.util.concurrent.Executor | 
getExecutor()  | 
protected ChainedHttpConfig | 
getObjectConfig()  | 
addCookieStore, configure, configure, configure, cookies, cookiesToAdd, delete, delete, delete, delete, delete, deleteAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, findCause, get, get, get, get, get, getAsync, getAsync, getAsync, getAsync, getAsync, getCookieManager, getCookieStore, handleException, head, head, head, head, head, headAsync, headAsync, headAsync, headAsync, headAsync, options, options, options, options, options, optionsAsync, optionsAsync, optionsAsync, optionsAsync, optionsAsync, patch, patch, patch, patch, patch, patchAsync, patchAsync, patchAsync, patchAsync, patchAsync, post, post, post, post, post, postAsync, postAsync, postAsync, postAsync, postAsync, put, put, put, put, put, putAsync, putAsync, putAsync, putAsync, putAsync, trace, trace, trace, trace, trace, traceAsync, traceAsync, traceAsync, traceAsync, traceAsyncpublic ApacheHttpBuilder(HttpObjectConfig config)
Creates a new HttpBuilder based on the Apache HTTP client. While it is acceptable to create a builder with this method, it is generally
preferred to use one of the static configure(…) methods.
config - the configuration objectpublic static HttpBuilder configure(@DelegatesTo(value=HttpObjectConfig.class) Closure closure)
Creates an HttpBuilder using the ApacheHttpBuilder factory instance configured with the provided configuration closure.
The configuration closure delegates to the HttpObjectConfig interface, which is an extension of the HttpConfig interface -
configuration properties from either may be applied to the global client configuration here. See the documentation for those interfaces for
configuration property details.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
}
closure - the configuration closure (delegated to HttpObjectConfig)HttpBuilderpublic static HttpBuilder configure(java.util.function.Consumer<HttpObjectConfig> configuration)
Creates an HttpBuilder using the ApacheHttpBuilder factory instance configured with the provided configuration function.
The configuration Consumer function accepts an instance of the HttpObjectConfig interface, which is an extension of the HttpConfig
interface - configuration properties from either may be applied to the global client configuration here. See the documentation for those interfaces for
configuration property details.
This configuration method is generally meant for use with standard Java.
HttpBuilder.configure(new Consumer<HttpObjectConfig>() {
public void accept(HttpObjectConfig config) {
config.getRequest().setUri(format("http://localhost:%d", serverRule.getPort()));
}
});
Or, using lambda expressions:
HttpBuilder.configure(config -> {
config.getRequest().setUri(format("http://localhost:%d", serverRule.getPort()));
});
configuration - the configuration function (accepting HttpObjectConfig)HttpBuilderpublic java.lang.Object getClientImplementation()
Retrieves the internal client implementation as an HttpClient instance.
getClientImplementation in class HttpBuilderHttpClientprotected ChainedHttpConfig getObjectConfig()
getObjectConfig in class HttpBuilderpublic java.util.concurrent.Executor getExecutor()
getExecutor in class HttpBuilderpublic void close()
protected java.lang.Object doGet(ChainedHttpConfig requestConfig)
doGet in class HttpBuilderprotected java.lang.Object doHead(ChainedHttpConfig requestConfig)
doHead in class HttpBuilderprotected java.lang.Object doPost(ChainedHttpConfig requestConfig)
doPost in class HttpBuilderprotected java.lang.Object doPut(ChainedHttpConfig requestConfig)
doPut in class HttpBuilderprotected java.lang.Object doPatch(ChainedHttpConfig requestConfig)
doPatch in class HttpBuilderprotected java.lang.Object doDelete(ChainedHttpConfig requestConfig)
doDelete in class HttpBuilderprotected java.lang.Object doOptions(ChainedHttpConfig config)
doOptions in class HttpBuilderprotected java.lang.Object doTrace(ChainedHttpConfig config)
doTrace in class HttpBuilder