Package com.atlan.net
Class HttpContent
java.lang.Object
com.atlan.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(Collection<KeyValuePair<String, String>> nameValueCollection) Builds a new HttpContent for name/value tuples encoded usingapplication/x-www-form-urlencodedMIME type.static HttpContentBuilds a new HttpContent for the provided string usingapplication/jsonMIME type.static HttpContentbuildMultipartFormDataContent(Collection<KeyValuePair<String, Object>> nameValueCollection, String filename) Builds a new HttpContent for name/value tuples encoded usingmultipart/form-dataMIME type.static HttpContentbuildMultipartFormDataContent(Collection<KeyValuePair<String, Object>> nameValueCollection, String boundary, String filename) 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
-
buildJSONEncodedContent
Builds a new HttpContent for the provided string usingapplication/jsonMIME type.- Parameters:
body- the JSON payload- Returns:
- the encoded HttpContent instance
-
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
-
stringContent
The request's content, as a string. -
buildMultipartFormDataContent
public static HttpContent buildMultipartFormDataContent(Collection<KeyValuePair<String, Object>> nameValueCollection, String filename) throws IOExceptionBuilds a new HttpContent for name/value tuples encoded usingmultipart/form-dataMIME type.- Parameters:
nameValueCollection- the collection of name/value tuples to encodefilename- 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 nullIOException
-
buildMultipartFormDataContent
public static HttpContent buildMultipartFormDataContent(Collection<KeyValuePair<String, Object>> nameValueCollection, String boundary, String filename) 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 boundaryfilename- 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 nullIOException
-
byteArrayContent
public byte[] byteArrayContent()The request's content, as a byte array. -
contentType
The value of theContent-Typeheader. -
equals
-
hashCode
public int hashCode() -
toString
-