Package com.atlan.net

Class HttpContent

java.lang.Object
com.atlan.net.HttpContent

public final class HttpContent extends Object
Represents the content of an HTTP request, i.e. the request's body. This class also holds the value of the Content-Type header, which can depend on the body in some cases (e.g. for multipart requests).
  • Method Details

    • buildJSONEncodedContent

      public static HttpContent buildJSONEncodedContent(String body)
      Builds a new HttpContent for the provided string using application/json MIME type.
      Parameters:
      body - the JSON payload
      Returns:
      the encoded HttpContent instance
    • buildFormURLEncodedContent

      public static HttpContent buildFormURLEncodedContent(Collection<KeyValuePair<String,String>> nameValueCollection) throws IOException
      Builds a new HttpContent for name/value tuples encoded using application/x-www-form-urlencoded MIME type.
      Parameters:
      nameValueCollection - the collection of name/value tuples to encode
      Returns:
      the encoded HttpContent instance
      Throws:
      IllegalArgumentException - if nameValueCollection is null
      IOException
    • stringContent

      public String stringContent()
      The request's content, as a string.
    • buildMultipartFormDataContent

      public static HttpContent buildMultipartFormDataContent(Collection<KeyValuePair<String,Object>> nameValueCollection, String filename) throws IOException
      Builds a new HttpContent for name/value tuples encoded using multipart/form-data MIME type.
      Parameters:
      nameValueCollection - the collection of name/value tuples to encode
      filename - name of the file read via an InputStream (for non-InputStream args can be null)
      Returns:
      the encoded HttpContent instance
      Throws:
      IllegalArgumentException - if nameValueCollection is null
      IOException
    • buildMultipartFormDataContent

      public static HttpContent buildMultipartFormDataContent(Collection<KeyValuePair<String,Object>> nameValueCollection, String boundary, String filename) throws IOException
      Builds a new HttpContent for name/value tuples encoded using multipart/form-data MIME type.
      Parameters:
      nameValueCollection - the collection of name/value tuples to encode
      boundary - the boundary
      filename - name of the file read via an InputStream (for non-InputStream args can be null)
      Returns:
      the encoded HttpContent instance
      Throws:
      IllegalArgumentException - if nameValueCollection is null
      IOException
    • byteArrayContent

      public byte[] byteArrayContent()
      The request's content, as a byte array.
    • contentType

      public String contentType()
      The value of the Content-Type header.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object