@Immutable
public interface RequestBody
Instance of this interface is returned by Request.body()
,
and can be modified using one of the methods below. When modification
is done, method back()
returns a modified instance of
Request
, for example:
new JdkRequest("http://my.example.com") .header("Content-Type", "application/x-www-form-urlencoded") .body() .formParam("name", "Jeff Lebowski") .formParam("age", "37") .formParam("employment", "none") .back() // returns a modified instance of Request .fetch()
Instances of this interface are immutable and thread-safe.
Modifier and Type | Interface and Description |
---|---|
static class |
RequestBody.Printable
Printer of byte array.
|
Modifier and Type | Method and Description |
---|---|
Request |
back()
Get back to the request it's related to.
|
RequestBody |
formParam(String name,
Object value)
Add form param.
|
RequestBody |
formParams(Map<String,String> params)
Add form params.
|
String |
get()
Get text content.
|
RequestBody |
set(byte[] body)
Set byte array content.
|
RequestBody |
set(javax.json.JsonStructure json)
Set JSON content.
|
RequestBody |
set(String body)
Set text content.
|
@NotNull(message="request is never NULL") Request back()
@NotNull(message="body is never NULL") RequestBody set(@NotNull(message="body can\'t be NULL") String body)
body
- Body content@NotNull(message="body is never NULL") RequestBody set(@NotNull(message="JSON structure can\'t be NULL") javax.json.JsonStructure json)
json
- JSON object@NotNull(message="modified body is never NULL") RequestBody set(@NotNull(message="body can\'t be NULL") byte[] body)
body
- Body content@NotNull(message="alternated body is never NULL") RequestBody formParam(@NotNull(message="form param name can\'t be NULL") String name, @NotNull(message="form param value can\'t be NULL") Object value)
name
- Query param namevalue
- Value of the query param to setCopyright © 2012–2014 jcabi.com. All rights reserved.