RequestOptionsWithBody¶
Builder options for HTTP methods that support a request body.
Extends the common options (headers, query params, auth) with methods for setting the request body. Available for POST, PUT, PATCH, DELETE, and OPTIONS.
After calling a body method, the return type narrows to RequestOptions
which does not expose body methods — this prevents accidentally setting the
body twice. The body is always optional: calling build() without setting
a body produces a request with no body.
Public Functions¶
header¶
Add a header to the request.
Parameters¶
Returns¶
query¶
Add a query parameter. Parameters are percent-encoded in build().
Parameters¶
Returns¶
basic_auth¶
Set the Authorization header using HTTP Basic authentication.
Parameters¶
Returns¶
bearer_auth¶
Set the Authorization header using a Bearer token.
Parameters¶
- token: String val
Returns¶
body¶
Set the request body as raw bytes.
Parameters¶
Returns¶
- RequestOptions ref
json_body¶
Set the request body to data and add Content-Type: application/json.
Parameters¶
- data: String val
Returns¶
- RequestOptions ref
form_body¶
URL-encode params via FormEncoder, set as body, and add
Content-Type: application/x-www-form-urlencoded.
Parameters¶
Returns¶
- RequestOptions ref
multipart_body¶
Set the request body from a MultipartFormData builder.
Sets Content-Type to multipart/form-data with the boundary.
Parameters¶
- form: MultipartFormData ref
Returns¶
- RequestOptions ref
build¶
Build the final HTTPRequest val.
Returns¶
- HTTPRequest val