Class RequestBody
java.lang.Object
com.eqixiac.equinix.core.http.request.RequestBody
The single request-body representation carried by an
EquinixRequest. An immutable
carrier in one of three shapes:
json(Object)- a Java payload object serialized to JSON;form(Map)-application/x-www-form-urlencodedform fields;bytes(byte[], String)- a pre-encoded raw body (e.g. a hand-builtmultipart/form-datapayload).
The wire entity is built from this carrier by RequestFactory at dispatch time - once
per attempt - so a JSON payload that is mutated between dispatches (the POST-search paging
pipeline advances the body's pagination offset) is re-serialized automatically. No transport
(Apache HttpClient) type appears in this class's API.
- Author:
- ianjones
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe shape of the body: a JSON payload, form fields, or pre-encoded raw bytes. -
Method Summary
Modifier and TypeMethodDescriptionstatic RequestBodyA pre-encoded raw body sent verbatim with the given entity content type (e.g. a hand-builtmultipart/form-datapayload; the request's own content-type header may carry additional parameters such as the multipart boundary).static RequestBodyAnapplication/x-www-form-urlencodedbody built from the given fields (field order is preserved on the wire).byte[]getBytes()getKind()The JSON payload object, ornullfor non-JSON bodies.static RequestBodyA body whose payload object is serialized to JSON at dispatch time, honoring the request's content type and any JacksonFilterProviderset on the request.
-
Method Details
-
json
A body whose payload object is serialized to JSON at dispatch time, honoring the request's content type and any JacksonFilterProviderset on the request.- Parameters:
payload- the object to serialize (nevernull)- Returns:
- the JSON body carrier
-
form
Anapplication/x-www-form-urlencodedbody built from the given fields (field order is preserved on the wire).- Parameters:
fields- the form field name/value pairs (nevernull; copied)- Returns:
- the form body carrier
-
bytes
A pre-encoded raw body sent verbatim with the given entity content type (e.g. a hand-builtmultipart/form-datapayload; the request's own content-type header may carry additional parameters such as the multipart boundary).- Parameters:
bytes- the raw body bytes (nevernull; copied)contentType- the entity content type (may benull)- Returns:
- the binary body carrier
-
getKind
- Returns:
- the shape of this body
-
getPayload
The JSON payload object, ornullfor non-JSON bodies. For POST-search requests this is the live search body whose pagination state the paging pipeline advances between pages.- Returns:
- the payload object of a
RequestBody.Kind.JSONbody, elsenull
-
getFormFields
- Returns:
- the unmodifiable form fields of a
RequestBody.Kind.FORMbody, elsenull
-
getBytes
public byte[] getBytes()- Returns:
- a copy of the raw bytes of a
RequestBody.Kind.BINARYbody, elsenull
-
getBinaryContentType
- Returns:
- the entity content type of a
RequestBody.Kind.BINARYbody, elsenull
-