Interface ClientRequest<T extends ClientRequest<T>>

Type Parameters:
T - type of the implementation, to support fluent API
All Known Subinterfaces:
FullClientRequest<T>, Http1ClientRequest, Http2ClientRequest
All Known Implementing Classes:
ClientRequestBase, HttpClientRequest

public interface ClientRequest<T extends ClientRequest<T>>
Request can be reused within a single thread, but it remembers all explicitly configured headers and URI. Implementation is not expected to be thread safe!
  • Method Details

    • uri

      default T uri(String uri)
      Configure URI.
      Parameters:
      uri - uri to resolve against base URI, or to use if absolute
      Returns:
      updated request
    • path

      default T path(String uri)
      Configure path to call.
      Parameters:
      uri - path
      Returns:
      updated request
    • tls

      T tls(Tls tls)
      TLS configuration for this specific request.
      Parameters:
      tls - tls configuration
      Returns:
      updated request
    • proxy

      T proxy(Proxy proxy)
      Proxy configuration for this specific request.
      Parameters:
      proxy - proxy configuration
      Returns:
      updated request
    • uri

      T uri(URI uri)
      Configure URI.
      Parameters:
      uri - uri to resolve against base URI, or to use if absolute
      Returns:
      updated request
    • uri

      T uri(ClientUri uri)
      Configure request URI. This always replaces the existing URI (even if base URI is configured).
      Parameters:
      uri - uri to resolve against base URI, or to use if absolute
      Returns:
      updated request
    • header

      T header(Header header)
      Set an HTTP header.
      Parameters:
      header - header to set
      Returns:
      updated request
    • header

      default T header(HeaderName name, String... values)
      Set an HTTP header.
      Parameters:
      name - header name
      values - header values
      Returns:
      updated request
    • header

      default T header(HeaderName name, List<String> values)
      Set an HTTP header with multiple values.
      Parameters:
      name - header name
      values - header values
      Returns:
      updated request
    • headers

      T headers(Headers headers)
      Configure headers. Copy all headers from supplied Headers instance.
      Parameters:
      headers - to copy
      Returns:
      updated request
    • headers

      T headers(Consumer<ClientRequestHeaders> headersConsumer)
      Update headers.
      Parameters:
      headersConsumer - consumer of client request headers
      Returns:
      updated request
    • accept

      default T accept(HttpMediaType... accepted)
      Accepted media types. Supports quality factor and wildcards.
      Parameters:
      accepted - media types to accept
      Returns:
      updated request
    • accept

      default T accept(MediaType... acceptedTypes)
      Accepted media types. Supports quality factor and wildcards.
      Parameters:
      acceptedTypes - media types to accept
      Returns:
      updated request
    • contentType

      default T contentType(MediaType contentType)
      Sets the content type of the request.
      Parameters:
      contentType - content type of the request.
      Returns:
      updated request
    • pathParam

      T pathParam(String name, String value)
      Replace a placeholder in URI with an actual value.
      Parameters:
      name - name of parameter
      value - value of parameter
      Returns:
      updated request
    • queryParam

      T queryParam(String name, String... values)
      Add query parameter.
      Parameters:
      name - name of parameter
      values - value(s) of parameter
      Returns:
      updated request
    • fragment

      default T fragment(String fragment)
      Set fragment of the URI.
      Parameters:
      fragment - fragment
      Returns:
      updated request
    • fragment

      T fragment(UriFragment fragment)
      Set fragment of the URI.
      Parameters:
      fragment - fragment
      Returns:
      updated request
    • followRedirects

      T followRedirects(boolean followRedirects)
      Whether to follow redirects.
      Parameters:
      followRedirects - follow redirects
      Returns:
      updated request
    • maxRedirects

      T maxRedirects(int maxRedirects)
      Max number of the followed redirects.
      Parameters:
      maxRedirects - max followed redirects
      Returns:
      updated request
    • followRedirects

      boolean followRedirects()
      Whether to follow redirects.
      Returns:
      follow redirects
    • maxRedirects

      int maxRedirects()
      Maximal number of redirects to follow. This is to prevent infinite redirects.
      Returns:
      max number of redirects
    • request

      default HttpClientResponse request()
      Request without an entity.
      Returns:
      response
    • headers

      Get a (mutable) instance of outgoing headers.
      Returns:
      client request headers
    • request

      default <E> ClientResponseTyped<E> request(Class<E> type)
      Request without sending an entity.
      Type Parameters:
      E - type of entity
      Parameters:
      type - type of entity
      Returns:
      correctly typed response
      See Also:
    • requestEntity

      default <E> E requestEntity(Class<E> type) throws HttpException
      Request entity without sending a request entity, asking for entity only. This method will fail if the status is not in successful family.
      Type Parameters:
      E - type of the entity to read from the response
      Parameters:
      type - type of requested entity
      Returns:
      correctly typed entity
      Throws:
      HttpException - in case the response status is not success
    • submit

      HttpClientResponse submit(Object entity)
      Submit an entity.
      Parameters:
      entity - request entity
      Returns:
      response
    • submit

      default <T> ClientResponseTyped<T> submit(Object entity, Class<T> requestedType)
      Submit an entity and request a specific type.
      Type Parameters:
      T - type of response entity
      Parameters:
      entity - request entity
      requestedType - type of response entity
      Returns:
      correctly typed response
    • outputStream

      HttpClientResponse outputStream(ClientRequest.OutputStreamHandler outputStreamConsumer)
      Handle output stream and submit the request.
      Parameters:
      outputStreamConsumer - output stream to write request entity
      Returns:
      response
    • outputStream

      default <T> ClientResponseTyped<T> outputStream(ClientRequest.OutputStreamHandler outputStreamConsumer, Class<T> requestedType)
      Handle output stream and request a specific type.
      Type Parameters:
      T - type of response entity
      Parameters:
      outputStreamConsumer - output stream consumer to write request entity
      requestedType - type of response entity
      Returns:
      correctly typed response
    • resolvedUri

      UriInfo resolvedUri()
      Resolved URI that will be used to invoke this request.
      Returns:
      URI to invoke
    • connection

      T connection(ClientConnection connection)
      This method is for explicit connection use by this request.
      Parameters:
      connection - connection to use for this request
      Returns:
      updated client request
    • skipUriEncoding

      T skipUriEncoding(boolean skip)
      Disable uri encoding.
      Parameters:
      skip - set to true to disable URI encoding (false by default)
      Returns:
      updated client request
    • property

      T property(String propertyName, String propertyValue)
      Add a property to be used by this request.
      Parameters:
      propertyName - property name
      propertyValue - property value
      Returns:
      updated builder instance
    • keepAlive

      T keepAlive(boolean keepAlive)
      Whether to use keep alive with this request.
      Parameters:
      keepAlive - use keep alive
      Returns:
      updated client request
    • readTimeout

      T readTimeout(Duration readTimeout)
      Read timeout for this request.
      Parameters:
      readTimeout - response read timeout
      Returns:
      updated client request
    • readContinueTimeout

      T readContinueTimeout(Duration readContinueTimeout)
      Read 100-Continue timeout for this request. This read timeout is used when 100-Continue is sent by the client, before it sends an entity.
      Parameters:
      readContinueTimeout - read 100-Continue timeout duration
      Returns:
      updated client request
      See Also:
      • HttpClientConfigBlueprint.readContinueTimeout()