Package: groovy.http

## [Groovy] Class HttpBuilder.RequestSpec

- groovy.http.HttpBuilder.RequestSpec

-     static final class HttpBuilder.RequestSpec
      extends Object

  Per-request configuration DSL used by the request methods.

  Since:
    6.0.0

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `Object` | `body` Request body value after any DSL serialization step.
    `HttpResponse.BodyHandler<String>` | `bodyHandler` Body handler used for buffered requests.
    `Map<String, String>` | `headers` Headers added only to the current request.
    `Map<String, Object>` | `queryParameters` Query parameters appended to the current request URI.
    `Duration` | `timeout` Request-specific timeout overriding the builder default.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `HttpBuilder.RequestSpec()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `void` | `asString()` Uses the default string body handler for buffered requests.
    `` | `void` | `body(Object value)` Sets the request body without further serialization.
    `` | `void` | `bytes(byte[] value)` Sets the request body to raw bytes.
    `` | `void` | `form(Map<String, ?> values)` Encodes map entries as application/x-www-form-urlencoded and sets a default content type.
    `` | `void` | `header(String name, Object value)` Adds a header to the current request.
    `` | `void` | `headers(Map<String, ?> values)` Adds multiple headers to the current request.
    `` | `void` | `json(Object value)` Serializes the given value as JSON and sets a default content type.
    `` | `void` | `query(String name, Object value)` Adds a query parameter to the current request.
    `` | `void` | `query(Map<String, ?> values)` Adds multiple query parameters to the current request.
    `` | `void` | `text(Object value)` Sets the request body to the string form of the supplied value.
    `` | `void` | `timeout(Duration value)` Sets the timeout for the current request.

  - ### Inherited Methods Summary

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

- - ### Property Detail

    - #### Object body

      Request body value after any DSL serialization step.

    - #### HttpResponse.BodyHandler<String> bodyHandler

      Body handler used for buffered requests.

    - #### final Map<String, String> headers

      Headers added only to the current request.

    - #### final Map<String, Object> queryParameters

      Query parameters appended to the current request URI.

    - #### Duration timeout

      Request-specific timeout overriding the builder default.

  - ### Constructor Detail

    - #### HttpBuilder.RequestSpec()

  - ### Method Detail

    - #### void asString()

      Uses the default string body handler for buffered requests.

    - #### void body(Object value)

      Sets the request body without further serialization.

      Parameters:
        `value` - the body value

    - #### void bytes(byte[] value)

      Sets the request body to raw bytes.

      Parameters:
        `value` - the binary payload

    - #### void form(Map<String, ?> values)

      Encodes map entries as application/x-www-form-urlencoded and sets a default content type.

      Parameters:
        `values` - the form fields to encode

    - #### void header(String name, Object value)

      Adds a header to the current request.

      Parameters:
        `name` - the header name
        `value` - the header value

    - #### void headers(Map<String, ?> values)

      Adds multiple headers to the current request.

      Parameters:
        `values` - the headers to add

    - #### void json(Object value)

      Serializes the given value as JSON and sets a default content type.

      Parameters:
        `value` - the value to serialize

    - #### void query(String name, Object value)

      Adds a query parameter to the current request.

      Parameters:
        `name` - the query parameter name
        `value` - the query parameter value

    - #### void query(Map<String, ?> values)

      Adds multiple query parameters to the current request.

      Parameters:
        `values` - the query parameters to add

    - #### void text(Object value)

      Sets the request body to the string form of the supplied value.

      Parameters:
        `value` - the text body value

    - #### void timeout(Duration value)

      Sets the timeout for the current request.

      Parameters:
        `value` - the request timeout