StringRequestEntity (HttpClient Library (Version 3.1))
Date: 2019-01-01

org.apache.commons.httpclient.methods

## Class StringRequestEntity

- java.lang.Object
- - org.apache.commons.httpclient.methods.StringRequestEntity

- All Implemented Interfaces:
    RequestEntity

      public class StringRequestEntity
      extends java.lang.Object
      implements RequestEntity

  A RequestEntity that contains a String.
  Since:
    3.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringRequestEntity(java.lang.String content)` Deprecated. use `StringRequestEntity(String, String, String)` instead
    `StringRequestEntity(java.lang.String content, java.lang.String contentType, java.lang.String charset)` Creates a new entity with the given content, content type, and charset.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getCharset()`
    `java.lang.String` | `getContent()`
    `long` | `getContentLength()` Gets the request entity's length.
    `java.lang.String` | `getContentType()` Gets the entity's content type.
    `boolean` | `isRepeatable()` Tests if `RequestEntity.writeRequest(OutputStream)` can be called more than once.
    `void` | `writeRequest(java.io.OutputStream out)` Writes the request entity to the given stream.

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

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

- - ### Constructor Detail

    - #### StringRequestEntity

          public StringRequestEntity(java.lang.String content)

      Deprecated. use `StringRequestEntity(String, String, String)` instead

      Creates a new entity with the given content. This constructor will use the default platform charset to convert the content string and will provide no content type.

      Parameters:
        `content` - The content to set.
      See Also:
        `StringRequestEntity(String, String, String)`

    - #### StringRequestEntity

          public StringRequestEntity(java.lang.String content,
                                     java.lang.String contentType,
                                     java.lang.String charset)
                              throws java.io.UnsupportedEncodingException

      Creates a new entity with the given content, content type, and charset.
      Parameters:
        `content` - The content to set.
        `contentType` - The type of the content, or `null`. The value retured by `getContentType()`. If this content type contains a charset and the charset parameter is null, the content's type charset will be used.
        `charset` - The charset of the content, or `null`. Used to convert the content to bytes. If the content type does not contain a charset and charset is not null, then the charset will be appended to the content type.
      Throws:
        `java.io.UnsupportedEncodingException`

  - ### Method Detail

    - #### getContentType

          public java.lang.String getContentType()

      Description copied from interface: `RequestEntity`
      Gets the entity's content type. This content type will be used as the value for the "Content-Type" header.
      Specified by:
        `getContentType` in interface `RequestEntity`
      Returns:
        the entity's content type
      See Also:
        `HttpMethod.setRequestHeader(String, String)`

    - #### isRepeatable

          public boolean isRepeatable()

      Description copied from interface: `RequestEntity`
      Tests if `RequestEntity.writeRequest(OutputStream)` can be called more than once.
      Specified by:
        `isRepeatable` in interface `RequestEntity`
      Returns:
        `true`

    - #### writeRequest

          public void writeRequest(java.io.OutputStream out)
                            throws java.io.IOException

      Description copied from interface: `RequestEntity`
      Writes the request entity to the given stream.
      Specified by:
        `writeRequest` in interface `RequestEntity`
      Throws:
        `java.io.IOException`

    - #### getContentLength

          public long getContentLength()

      Description copied from interface: `RequestEntity`
      Gets the request entity's length. This method should return a non-negative value if the content length is known or a negative value if it is not. In the latter case the `EntityEnclosingMethod` will use chunk encoding to transmit the request entity.
      Specified by:
        `getContentLength` in interface `RequestEntity`
      Returns:
        The length of the content.

    - #### getContent

          public java.lang.String getContent()

      Returns:
        Returns the content.

    - #### getCharset

          public java.lang.String getCharset()

      Returns:
        Returns the charset used to convert the content to bytes. `null` if no charset as been specified.

Copyright (c) 1999-2005 - Apache Software Foundation