Class HttpContent

java.lang.Object
com.stripe.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

    • 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) 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
      Returns:
      the encoded HttpContent instance
      Throws:
      IllegalArgumentException - if nameValueCollection is null
      IOException
    • buildMultipartFormDataContent

      public static HttpContent buildMultipartFormDataContent(Collection<KeyValuePair<String,Object>> nameValueCollection, String boundary) 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
      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