Liking cljdoc? Tell your friends :D

ol.sfv

RFC 9651 Structured Field Values for HTTP.

See the project website for info on motivation and design: https://github.com/outskirtslabs/sfv

This ns provides parsing and serialization of Structured Fields containing Items, Lists, and Dictionaries with Parameters. Returns precise AST representations that round-trip byte-for-byte with RFC 9651 strings.

Primary functions: parse, parse-item, parse-list, parse-dict, serialize

Conventions

  • s-or-bytes: Input string or byte array (decoded as ascii) containing HTTP field value
  • field-type: One of :item, :list, or :dict specifying the top-level structure
  • :bare: The raw value within an Item (Integer, Decimal, String, Token, Byte Sequence, Boolean, Date, or Display String)

Primitive Types

Each Item's :bare is one of these RFC 9651 types:

SFV typeHeaderAST exampleClojure type (:value)
Integer42, -17, 999999999999999{:type :integer :value 1618884473}long
Decimal3.14, -0.5{:type :decimal :value 3.14M}BigDecimal
String" hello world "{:type :string :value " hello "}java.lang.String
Tokensimple-token{:type :token :value " simple-token "}String
Byte Sequence:SGVsbG8=:{:type :bytes :value <platform bytes>}byte[]
Boolean?1 / ?0{:type :boolean :value true}true / false
Date@1659578233{:type :date :value 1659578233}epoch seconds as long
Display String%" Gr%c3%bc%c3%9fe "{:type :display :value " Grüße "}String (percent-decoded, validated)
RFC 9651 Structured Field Values for HTTP.

See the project website for info on motivation and design:
<https://github.com/outskirtslabs/sfv>

This ns provides parsing and serialization of Structured Fields containing
Items, Lists, and Dictionaries with Parameters. Returns precise AST
representations that round-trip byte-for-byte with RFC 9651 strings.

Primary functions: [[parse]], [[parse-item]], [[parse-list]], [[parse-dict]],
[[serialize]]

## Conventions

- `s-or-bytes`: Input string or byte array (decoded as ascii) containing HTTP field value
- `field-type`: One of `:item`, `:list`, or `:dict` specifying the top-level structure
- `:bare`: The raw value within an Item (Integer, Decimal, String, Token, Byte Sequence, Boolean, Date, or Display String)

## Primitive Types

Each Item's `:bare` is one of these RFC 9651 types:

| SFV type       | Header                         | AST example                                | Clojure type (`:value`)               |
|----------------|--------------------------------|--------------------------------------------|---------------------------------------|
| Integer        | `42`, `-17`, `999999999999999` | `{:type :integer :value 1618884473}`       | `long`                                |
| Decimal        | `3.14`, `-0.5`                 | `{:type :decimal :value 3.14M}`            | `BigDecimal`                          |
| String         | `" hello world "`            | `{:type :string :value " hello "}`       | `java.lang.String`                    |
| Token          | `simple-token`                 | `{:type :token :value " simple-token "}` | `String`                              |
| Byte Sequence  | `:SGVsbG8=:`                   | `{:type :bytes :value <platform bytes>}`   | `byte[]`                              |
| Boolean        | `?1` / `?0`                    | `{:type :boolean :value true}`             | `true` / `false`                      |
| Date           | `@1659578233`                  | `{:type :date :value 1659578233}`          | epoch seconds as `long`               |
| Display String | `%" Gr%c3%bc%c3%9fe "`       | `{:type :display :value " Grüße "}`      | `String` (percent-decoded, validated) |
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close