Package: groovy.http

## [Groovy] Class HttpClientHelper

- groovy.http.HttpClientHelper

-     @Incubating
      final class HttpClientHelper
      extends Object

  Runtime helper used by the generated declarative HTTP client implementations. Not intended for direct use.

  Since:
    6.0.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `HttpClientHelper(String baseUrl, Map<String, String> defaultHeaders)` Creates a helper with default timeout and redirect settings.
    `HttpClientHelper(String baseUrl, Map<String, String> defaultHeaders, int connectTimeoutSeconds, int requestTimeoutSeconds, boolean followRedirects)` Creates a helper backed by a new HttpBuilder.
    `HttpClientHelper(HttpBuilder http, Map<String, String> defaultHeaders)` Constructor accepting a pre-configured HttpBuilder instance.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `Object` | `execute(String method, String urlTemplate, String returnTypeName, Map<String, Object> pathParams, Map<String, Object> queryOrFormParams, Map<String, String> headers, Object body, int timeoutSeconds, String bodyMode, String errorTypeName)` Execute an HTTP request synchronously.
    `` | `CompletableFuture<Object>` | `executeAsync(String method, String urlTemplate, String returnTypeName, Map<String, Object> pathParams, Map<String, Object> queryOrFormParams, Map<String, String> headers, Object body, int timeoutSeconds, String bodyMode, String errorTypeName)` Execute an HTTP request asynchronously.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HttpClientHelper(String baseUrl, Map<String, String> defaultHeaders)

      Creates a helper with default timeout and redirect settings.

      Parameters:
        `baseUrl` - the base URL used by generated clients
        `defaultHeaders` - the headers applied to every request

    - #### HttpClientHelper(String baseUrl, Map<String, String> defaultHeaders, int connectTimeoutSeconds, int requestTimeoutSeconds, boolean followRedirects)

      Creates a helper backed by a new HttpBuilder.

      Parameters:
        `baseUrl` - the base URL used by generated clients
        `defaultHeaders` - the headers applied to every request
        `connectTimeoutSeconds` - the connect timeout in seconds, or `0` for none
        `requestTimeoutSeconds` - the request timeout in seconds, or `0` for none
        `followRedirects` - whether redirects should be followed automatically

    - #### HttpClientHelper(HttpBuilder http, Map<String, String> defaultHeaders)

      Constructor accepting a pre-configured HttpBuilder instance. Used by the create(Closure) factory for advanced configuration.

      Parameters:
        `http` - the pre-configured HTTP builder to reuse
        `defaultHeaders` - the headers applied to every request

  - ### Method Detail

    - #### Object execute(String method, String urlTemplate, String returnTypeName, Map<String, Object> pathParams, Map<String, Object> queryOrFormParams, Map<String, String> headers, Object body, int timeoutSeconds, String bodyMode, String errorTypeName)

      Execute an HTTP request synchronously.

      Parameters:
        `method` - HTTP method (GET, POST, PUT, DELETE, PATCH)
        `urlTemplate` - URL template with {param} placeholders
        `returnTypeName` - the method's return type name for response conversion
        `pathParams` - map of path parameter names to values
        `queryOrFormParams` - map of query parameter names or form fields to values
        `headers` - map of additional headers for this request
        `body` - request body (serialized as JSON if non-null)
        `timeoutSeconds` - per-request timeout in seconds, or `0` for none
        `bodyMode` - serialization mode for the request body
        `errorTypeName` - fully qualified exception type used for HTTP error responses
      Returns:
        the converted response

    - #### CompletableFuture<Object> executeAsync(String method, String urlTemplate, String returnTypeName, Map<String, Object> pathParams, Map<String, Object> queryOrFormParams, Map<String, String> headers, Object body, int timeoutSeconds, String bodyMode, String errorTypeName)

      Execute an HTTP request asynchronously.

      Parameters:
        `method` - HTTP method (GET, POST, PUT, DELETE, PATCH)
        `urlTemplate` - URL template with {param} placeholders
        `returnTypeName` - the method's return type name for response conversion
        `pathParams` - map of path parameter names to values
        `queryOrFormParams` - map of query parameter names or form fields to values
        `headers` - map of additional headers for this request
        `body` - request body before serialization
        `timeoutSeconds` - per-request timeout in seconds, or `0` for none
        `bodyMode` - serialization mode for the request body
        `errorTypeName` - fully qualified exception type used for HTTP error responses
      Returns:
        a CompletableFuture containing the converted response