Skip to content

RequestOptionsWithBody

[Source]

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.

interface ref RequestOptionsWithBody

Public Functions

[Source]

Add a header to the request.

fun ref header(
  hdr_name: String val,
  hdr_value: String val)
: RequestOptionsWithBody ref

Parameters

Returns


query

[Source]

Add a query parameter. Parameters are percent-encoded in build().

fun ref query(
  key: String val,
  value: String val)
: RequestOptionsWithBody ref

Parameters

Returns


basic_auth

[Source]

Set the Authorization header using HTTP Basic authentication.

fun ref basic_auth(
  username: String val,
  password: String val)
: RequestOptionsWithBody ref

Parameters

Returns


bearer_auth

[Source]

Set the Authorization header using a Bearer token.

fun ref bearer_auth(
  token: String val)
: RequestOptionsWithBody ref

Parameters

Returns


body

[Source]

Set the request body as raw bytes.

fun ref body(
  data: Array[U8 val] val)
: RequestOptions ref

Parameters

Returns


json_body

[Source]

Set the request body to data and add Content-Type: application/json.

fun ref json_body(
  data: String val)
: RequestOptions ref

Parameters

Returns


form_body

[Source]

URL-encode params via FormEncoder, set as body, and add Content-Type: application/x-www-form-urlencoded.

fun ref form_body(
  params: Array[(String val , String val)] val)
: RequestOptions ref

Parameters

Returns


multipart_body

[Source]

Set the request body from a MultipartFormData builder.

Sets Content-Type to multipart/form-data with the boundary.

fun ref multipart_body(
  form: MultipartFormData ref)
: RequestOptions ref

Parameters

Returns


build

[Source]

Build the final HTTPRequest val.

fun ref build()
: HTTPRequest val

Returns