Package kong.unirest.core
Interface HttpRequestWithBody
-
- All Superinterfaces:
HttpRequest<HttpRequestWithBody>
public interface HttpRequestWithBody extends HttpRequest<HttpRequestWithBody>
A request Builder for POST and PUT operations with a body. will switch to a MultipartBody once http form variables are introduced. or to a RequestBodyEntity
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description RequestBodyEntitybody(byte[] body)Set a byte array as the body of the requestRequestBodyEntitybody(InputStream body)Set a InputStream as the bodyRequestBodyEntitybody(Object body)Set a Object as the body of the request.RequestBodyEntitybody(String body)Set a String as the body of the requestRequestBodyEntitybody(JSONElement body)Set JSON on the bodyRequestBodyEntitybody(JsonNode body)Set JSON on the bodyHttpRequestWithBodycharset(Charset charset)Set the Charset encoding for the Content-Type.HttpRequestWithBodycontentType(String type)MultipartBodyfield(String name, File file)Sets a File on the body.MultipartBodyfield(String name, File file, String contentType)Sets a File on the body with a specified content-type.MultipartBodyfield(String name, InputStream stream, String fileName)Sets a File on the body from a raw InputStream requires a file name.MultipartBodyfield(String name, InputStream stream, ContentType contentType, String fileName)Sets a File on the body from a raw InputStream requires a specified content-type and file name.MultipartBodyfield(String name, Object value)Sets a field param on the body.MultipartBodyfield(String name, Object value, String contentType)Sets a field param on the body with a specified content-type.MultipartBodyfield(String name, Collection<?> value)Sets multiple field params on the body each with the same name.MultipartBodyfields(Map<String,Object> parameters)Sets multiple field params on the body from a map of key/value pairs.CharsetgetCharset()get the current default charsetMultipartBodymultiPartContent()Forces the request to send as multipart even if all params are simpledefault HttpRequestWithBodynoCharset()Removes any Charset for the Content-Type for when servers cannot process it.-
Methods inherited from interface kong.unirest.core.HttpRequest
accept, asBytes, asBytesAsync, asBytesAsync, asEmpty, asEmptyAsync, asEmptyAsync, asFile, asFileAsync, asFileAsync, asJson, asJsonAsync, asJsonAsync, asObject, asObject, asObject, asObjectAsync, asObjectAsync, asObjectAsync, asObjectAsync, asObjectAsync, asPaged, asString, asStringAsync, asStringAsync, basicAuth, connectTimeout, cookie, cookie, cookie, downloadMonitor, getBody, getConnectTimeout, getCreationTime, getHeaders, getHttpMethod, getUrl, getVersion, header, headerReplace, headers, headersReplace, queryString, queryString, queryString, responseEncoding, routeParam, routeParam, thenConsume, thenConsumeAsync, toSummary, version, withObjectMapper
-
-
-
-
Method Detail
-
multiPartContent
MultipartBody multiPartContent()
Forces the request to send as multipart even if all params are simple- Returns:
- The same MultipartBody
-
field
MultipartBody field(String name, Object value)
Sets a field param on the body.- Parameters:
name- the name of the fieldvalue- a values- Returns:
- this request builder
-
field
MultipartBody field(String name, Collection<?> value)
Sets multiple field params on the body each with the same name.- Parameters:
name- the name of the fieldvalue- a Collection of values- Returns:
- this request builder
-
field
MultipartBody field(String name, Object value, String contentType)
Sets a field param on the body with a specified content-type.- Parameters:
name- the name of the fieldvalue- the objectcontentType- contentType (i.e. application/xml)- Returns:
- this request builder
-
fields
MultipartBody fields(Map<String,Object> parameters)
Sets multiple field params on the body from a map of key/value pairs.- Parameters:
parameters- the map of field params- Returns:
- this request builder
-
field
MultipartBody field(String name, File file)
Sets a File on the body.- Parameters:
name- the name of the file fieldfile- the file- Returns:
- this request builder
-
field
MultipartBody field(String name, File file, String contentType)
Sets a File on the body with a specified content-type.- Parameters:
name- the name of the file fieldfile- the filecontentType- contentType (i.e. image/png)- Returns:
- this request builder
-
field
MultipartBody field(String name, InputStream stream, String fileName)
Sets a File on the body from a raw InputStream requires a file name.- Parameters:
name- the name of the file fieldstream- the inputStreamfileName- the name for the file- Returns:
- this request builder
-
field
MultipartBody field(String name, InputStream stream, ContentType contentType, String fileName)
Sets a File on the body from a raw InputStream requires a specified content-type and file name.- Parameters:
name- the name of the file fieldstream- the inputStreamcontentType- contentType (i.e. image/png)fileName- the name for the file- Returns:
- this request builder
-
charset
HttpRequestWithBody charset(Charset charset)
Set the Charset encoding for the Content-Type. This is appended to the Content-Type Header (e.g. application/x-www-form-urlencoded; charset=US-ASCII) Default is UTF-8- Parameters:
charset- the charset- Returns:
- this request builder
-
noCharset
default HttpRequestWithBody noCharset()
Removes any Charset for the Content-Type for when servers cannot process it. (e.g. application/x-www-form-urlencoded)- Returns:
- this request builder
-
body
RequestBodyEntity body(String body)
Set a String as the body of the request- Parameters:
body- the String- Returns:
- this request builder
-
body
RequestBodyEntity body(InputStream body)
Set a InputStream as the body- Parameters:
body- the Object- Returns:
- this request builder
-
body
RequestBodyEntity body(Object body)
Set a Object as the body of the request. This will be serialized with one of the following methods: - Strings are native - JSONElements use their native toString - Everything else will pass through the supplied ObjectMapper- Parameters:
body- the Object- Returns:
- this request builder
-
body
RequestBodyEntity body(byte[] body)
Set a byte array as the body of the request- Parameters:
body- the byte[]- Returns:
- this request builder
-
body
RequestBodyEntity body(JsonNode body)
Set JSON on the body- Parameters:
body- the JsonNode- Returns:
- this request builder
-
body
RequestBodyEntity body(JSONElement body)
Set JSON on the body- Parameters:
body- the JSONElement- Returns:
- this request builder
-
getCharset
Charset getCharset()
get the current default charset- Returns:
- the Charset
-
contentType
HttpRequestWithBody contentType(String type)
- Parameters:
type- The content mime type- Returns:
- this request builder
-
-