org.apache.hc.client5.http.async.methods

## Class SimpleHttpRequest

- java.lang.Object
- - org.apache.hc.core5.http.message.HeaderGroup
  - - org.apache.hc.core5.http.message.BasicHttpRequest
    - - org.apache.hc.client5.http.async.methods.ConfigurableHttpRequest
      - - org.apache.hc.client5.http.async.methods.SimpleHttpRequest

- All Implemented Interfaces:
    Serializable, Configurable, HttpMessage, HttpRequest, MessageHeaders

      public final class SimpleHttpRequest
      extends ConfigurableHttpRequest

  HTTP request that can enclose a body represented as a simple text string or an array of bytes.

  IMPORTANT: `SimpleHttpRequest`s are intended for simple scenarios where entities inclosed in requests are known to be small. It is generally recommended to use `AsyncRequestBuilder` and streaming `AsyncEntityProducer`s.

  Since:
    5.0
  See Also:
    `SimpleBody`, `AsyncRequestBuilder`, `AsyncEntityProducer`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleHttpRequest(Method method, HttpHost host, String path)`
    `SimpleHttpRequest(Method method, URI requestUri)`
    `SimpleHttpRequest(String method, HttpHost host, String path)`
    `SimpleHttpRequest(String method, String path)`
    `SimpleHttpRequest(String method, String scheme, URIAuthority authority, String path)`
    `SimpleHttpRequest(String method, URI requestUri)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static SimpleHttpRequest` | `copy(HttpRequest original)` Deprecated. Use `SimpleRequestBuilder`
    `static SimpleHttpRequest` | `create(Method method, HttpHost host, String path)`
    `static SimpleHttpRequest` | `create(Method method, URI uri)`
    `static SimpleHttpRequest` | `create(String method, String uri)`
    `static SimpleHttpRequest` | `create(String method, String scheme, URIAuthority authority, String path)`
    `static SimpleHttpRequest` | `create(String method, URI uri)`
    `SimpleBody` | `getBody()`
    `byte[]` | `getBodyBytes()`
    `String` | `getBodyText()`
    `ContentType` | `getContentType()`
    `void` | `setBody(byte[] bodyBytes, ContentType contentType)`
    `void` | `setBody(SimpleBody body)`
    `void` | `setBody(String bodyText, ContentType contentType)`

    - ### Methods inherited from class org.apache.hc.client5.http.async.methods.ConfigurableHttpRequest

      `getConfig, setConfig`

    - ### Methods inherited from class org.apache.hc.core5.http.message.BasicHttpRequest

      `addHeader, getAuthority, getMethod, getPath, getRequestUri, getScheme, getUri, getVersion, setAbsoluteRequestUri, setAuthority, setHeader, setPath, setScheme, setUri, setVersion, toString`

    - ### Methods inherited from class org.apache.hc.core5.http.message.HeaderGroup

      `addHeader, clear, containsHeader, countHeaders, getCondensedHeader, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator, removeHeader, removeHeaders, removeHeaders, setHeader, setHeaders`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.hc.core5.http.HttpMessage

      `addHeader, removeHeader, removeHeaders, setHeader, setHeaders`

    - ### Methods inherited from interface org.apache.hc.core5.http.MessageHeaders

      `containsHeader, countHeaders, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator`

- - ### Constructor Detail

    - #### SimpleHttpRequest

          public SimpleHttpRequest(String method,
                                   String path)

    - #### SimpleHttpRequest

          public SimpleHttpRequest(String method,
                                   HttpHost host,
                                   String path)

    - #### SimpleHttpRequest

          public SimpleHttpRequest(String method,
                                   URI requestUri)

    - #### SimpleHttpRequest

          public SimpleHttpRequest(Method method,
                                   URI requestUri)

      Since:
        5.1

    - #### SimpleHttpRequest

          public SimpleHttpRequest(Method method,
                                   HttpHost host,
                                   String path)

      Since:
        5.1

    - #### SimpleHttpRequest

          public SimpleHttpRequest(String method,
                                   String scheme,
                                   URIAuthority authority,
                                   String path)

      Since:
        5.1

  - ### Method Detail

    - #### create

          public static SimpleHttpRequest create(String method,
                                                 String uri)

      Since:
        5.1

    - #### create

          public static SimpleHttpRequest create(String method,
                                                 URI uri)

      Since:
        5.1

    - #### create

          public static SimpleHttpRequest create(Method method,
                                                 URI uri)

      Since:
        5.1

    - #### create

          public static SimpleHttpRequest create(Method method,
                                                 HttpHost host,
                                                 String path)

      Since:
        5.1

    - #### create

          public static SimpleHttpRequest create(String method,
                                                 String scheme,
                                                 URIAuthority authority,
                                                 String path)

      Since:
        5.1

    - #### copy

          @Deprecated
          public static SimpleHttpRequest copy(HttpRequest original)

      Deprecated. Use `SimpleRequestBuilder`

    - #### setBody

          public void setBody(SimpleBody body)

    - #### setBody

          public void setBody(byte[] bodyBytes,
                              ContentType contentType)

    - #### setBody

          public void setBody(String bodyText,
                              ContentType contentType)

    - #### getBody

          public SimpleBody getBody()

    - #### getContentType

          public ContentType getContentType()

    - #### getBodyText

          public String getBodyText()

    - #### getBodyBytes

          public byte[] getBodyBytes()

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.