Package com.jcabi.http
Interface RequestBody
-
@Immutable public interface RequestBody
Request body.Instance of this interface is returned by
Request.body()
, and can be modified using one of the methods below. When modification is done, methodback()
returns a modified instance ofRequest
, 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.
- Since:
- 0.8
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
RequestBody.Printable
Printer of byte array.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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(String body)
Set text content.RequestBody
set(javax.json.JsonStructure json)
Set JSON content.
-
-
-
Method Detail
-
back
Request back()
Get back to the request it's related to.- Returns:
- The request we're in
-
get
String get()
Get text content.- Returns:
- Content in UTF-8
-
set
RequestBody set(String body)
Set text content.- Parameters:
body
- Body content- Returns:
- New alternated body
-
set
RequestBody set(javax.json.JsonStructure json)
Set JSON content.- Parameters:
json
- JSON object- Returns:
- New alternated body
- Since:
- 0.11
-
set
RequestBody set(byte[] body)
Set byte array content.- Parameters:
body
- Body content- Returns:
- New alternated body
-
formParam
RequestBody formParam(String name, Object value)
Add form param.- Parameters:
name
- Query param namevalue
- Value of the query param to set- Returns:
- New alternated body
-
formParams
RequestBody formParams(Map<String,String> params)
Add form params.- Parameters:
params
- Map of params- Returns:
- New alternated body
- Since:
- 0.10
-
-