Skip to content

FormURLEncoded

[Source]

Parsed application/x-www-form-urlencoded key-value pairs with lookup.

This format is used for both URI query strings and HTTP POST request bodies. Stores decoded key-value pairs in their original order. Duplicate keys are preserved — use get() for the first value or get_all() for every value associated with a key. Lookups are linear scans, which is appropriate for the small pair counts typical of form-encoded data.

For URI query strings, URI.query_params() is a convenience wrapper that calls ParseFormURLEncoded on the URI's query component. For HTTP POST bodies, call ParseFormURLEncoded directly on the body string.

class val FormURLEncoded

Constructors

create

[Source]

Create from an array of decoded key-value pairs.

new val create(
  p: Array[(String val , String val)] val)
: FormURLEncoded val^

Parameters

Returns


Public Functions

apply

[Source]

The pair at index i. Raises an error if out of bounds.

fun box apply(
  i: USize val)
: (String val , String val) ?

Parameters

Returns


get

[Source]

First value for key, or None if the key is absent.

When duplicate keys are possible and all values are needed, use get_all() instead.

fun box get(
  key: String val)
: (String val | None val)

Parameters

Returns


get_all

[Source]

All values for key, in order. Empty array if absent.

fun box get_all(
  key: String val)
: Array[String val] val

Parameters

Returns


contains

[Source]

Whether key is present.

fun box contains(
  key: String val)
: Bool val

Parameters

Returns


pairs

[Source]

All pairs in their original order.

fun box pairs()
: ArrayValues[(String val , String val), Array[(String val , String val)] val] ref^

Returns


size

[Source]

Number of pairs, including duplicates.

fun box size()
: USize val

Returns