Package com.stripe.net
Class HttpContent
java.lang.Object
com.stripe.net.HttpContent
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 Summary
Modifier and TypeMethodDescriptionstatic HttpContentbuildFormURLEncodedContent(String content) Builds a new HttpContent for name/value tuples encoded usingapplication/x-www-form-urlencodedMIME type.static HttpContentbuildFormURLEncodedContent(Collection<KeyValuePair<String, String>> nameValueCollection) Builds a new HttpContent for name/value tuples encoded usingapplication/x-www-form-urlencodedMIME type.static HttpContentbuildJsonContent(String json) Builds a new HttpContent forapplication/jsonMIME type.static HttpContentbuildMultipartFormDataContent(Collection<KeyValuePair<String, Object>> nameValueCollection) Builds a new HttpContent for name/value tuples encoded usingmultipart/form-dataMIME type.static HttpContentbuildMultipartFormDataContent(Collection<KeyValuePair<String, Object>> nameValueCollection, String boundary) Builds a new HttpContent for name/value tuples encoded usingmultipart/form-dataMIME type.byte[]The request's content, as a byte array.The value of theContent-Typeheader.booleaninthashCode()The request's content, as a string.toString()
-
Method Details
-
buildFormURLEncodedContent
public static HttpContent buildFormURLEncodedContent(Collection<KeyValuePair<String, String>> nameValueCollection) throws IOExceptionBuilds a new HttpContent for name/value tuples encoded usingapplication/x-www-form-urlencodedMIME type.- Parameters:
nameValueCollection- the collection of name/value tuples to encode- Returns:
- the encoded HttpContent instance
- Throws:
IllegalArgumentException- if nameValueCollection is nullIOException
-
buildFormURLEncodedContent
Builds a new HttpContent for name/value tuples encoded usingapplication/x-www-form-urlencodedMIME type.- Parameters:
content- the form-encoded content string- Returns:
- the encoded HttpContent instance
- Throws:
IllegalArgumentException- if nameValueCollection is nullIOException
-
stringContent
The request's content, as a string. -
buildMultipartFormDataContent
public static HttpContent buildMultipartFormDataContent(Collection<KeyValuePair<String, Object>> nameValueCollection) throws IOExceptionBuilds a new HttpContent for name/value tuples encoded usingmultipart/form-dataMIME type.- Parameters:
nameValueCollection- the collection of name/value tuples to encode- Returns:
- the encoded HttpContent instance
- Throws:
IllegalArgumentException- if nameValueCollection is nullIOException
-
buildMultipartFormDataContent
public static HttpContent buildMultipartFormDataContent(Collection<KeyValuePair<String, Object>> nameValueCollection, String boundary) throws IOExceptionBuilds a new HttpContent for name/value tuples encoded usingmultipart/form-dataMIME type.- Parameters:
nameValueCollection- the collection of name/value tuples to encodeboundary- the boundary- Returns:
- the encoded HttpContent instance
- Throws:
IllegalArgumentException- if nameValueCollection is nullIOException
-
buildJsonContent
Builds a new HttpContent forapplication/jsonMIME type.- Parameters:
json- the JSON value- Returns:
- the encoded HttpContent instance
- Throws:
IllegalArgumentException- if nameValueCollection is null
-
byteArrayContent
public byte[] byteArrayContent()The request's content, as a byte array. -
contentType
The value of theContent-Typeheader. -
equals
-
hashCode
public int hashCode() -
toString
-