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 HttpContent
buildFormURLEncodedContent
(Collection<KeyValuePair<String, String>> nameValueCollection) Builds a new HttpContent for name/value tuples encoded usingapplication/x-www-form-urlencoded
MIME type.static HttpContent
Builds a new HttpContent for the provided string usingapplication/json
MIME type.static HttpContent
buildMultipartFormDataContent
(Collection<KeyValuePair<String, Object>> nameValueCollection, String filename) Builds a new HttpContent for name/value tuples encoded usingmultipart/form-data
MIME type.static HttpContent
buildMultipartFormDataContent
(Collection<KeyValuePair<String, Object>> nameValueCollection, String boundary, String filename) Builds a new HttpContent for name/value tuples encoded usingmultipart/form-data
MIME type.byte[]
The request's content, as a byte array.The value of theContent-Type
header.boolean
int
hashCode()
The request's content, as a string.toString()
-
Method Details
-
buildJSONEncodedContent
Builds a new HttpContent for the provided string usingapplication/json
MIME 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-urlencoded
MIME 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-data
MIME 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-data
MIME 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-Type
header. -
equals
-
hashCode
public int hashCode() -
toString
-