def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
}
public class ApacheHttpBuilder
extends groovyx.net.http.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 |
| Constructor and Description |
|---|
ApacheHttpBuilder(groovyx.net.http.HttpObjectConfig config)
Creates a new
HttpBuilder based on the Apache HTTP client. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static groovyx.net.http.HttpBuilder |
configure(Closure closure)
Creates an
HttpBuilder using the ApacheHttpBuilder factory instance configured with the provided configuration closure. |
static groovyx.net.http.HttpBuilder |
configure(java.util.function.Consumer<groovyx.net.http.HttpObjectConfig> configuration)
Creates an
HttpBuilder using the ApacheHttpBuilder factory instance configured with the provided configuration function. |
protected java.lang.Object |
doDelete(groovyx.net.http.ChainedHttpConfig requestConfig) |
protected java.lang.Object |
doGet(groovyx.net.http.ChainedHttpConfig requestConfig) |
protected java.lang.Object |
doHead(groovyx.net.http.ChainedHttpConfig requestConfig) |
protected java.lang.Object |
doOptions(groovyx.net.http.ChainedHttpConfig config) |
protected java.lang.Object |
doPatch(groovyx.net.http.ChainedHttpConfig requestConfig) |
protected java.lang.Object |
doPost(groovyx.net.http.ChainedHttpConfig requestConfig) |
protected java.lang.Object |
doPut(groovyx.net.http.ChainedHttpConfig requestConfig) |
protected java.lang.Object |
doTrace(groovyx.net.http.ChainedHttpConfig config) |
java.lang.Object |
getClientImplementation()
Retrieves the internal client implementation as an
HttpClient instance. |
java.util.concurrent.Executor |
getExecutor() |
protected groovyx.net.http.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(groovyx.net.http.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 groovyx.net.http.HttpBuilder configure(@DelegatesTo(value=groovyx.net.http.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 groovyx.net.http.HttpBuilder configure(java.util.function.Consumer<groovyx.net.http.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 groovyx.net.http.HttpBuilderHttpClientprotected groovyx.net.http.ChainedHttpConfig getObjectConfig()
getObjectConfig in class groovyx.net.http.HttpBuilderpublic java.util.concurrent.Executor getExecutor()
getExecutor in class groovyx.net.http.HttpBuilderpublic void close()
protected java.lang.Object doGet(groovyx.net.http.ChainedHttpConfig requestConfig)
doGet in class groovyx.net.http.HttpBuilderprotected java.lang.Object doHead(groovyx.net.http.ChainedHttpConfig requestConfig)
doHead in class groovyx.net.http.HttpBuilderprotected java.lang.Object doPost(groovyx.net.http.ChainedHttpConfig requestConfig)
doPost in class groovyx.net.http.HttpBuilderprotected java.lang.Object doPut(groovyx.net.http.ChainedHttpConfig requestConfig)
doPut in class groovyx.net.http.HttpBuilderprotected java.lang.Object doPatch(groovyx.net.http.ChainedHttpConfig requestConfig)
doPatch in class groovyx.net.http.HttpBuilderprotected java.lang.Object doDelete(groovyx.net.http.ChainedHttpConfig requestConfig)
doDelete in class groovyx.net.http.HttpBuilderprotected java.lang.Object doOptions(groovyx.net.http.ChainedHttpConfig config)
doOptions in class groovyx.net.http.HttpBuilderprotected java.lang.Object doTrace(groovyx.net.http.ChainedHttpConfig config)
doTrace in class groovyx.net.http.HttpBuilder