Chunk #
This module defines the Chunk type, which represents a chunk of data from a request or response.
Reference: https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1
A proposition stating that s is a valid chunk-extension name: every character in s is an
HTTP token character and s is non-empty.
Reference: https://httpwg.org/specs/rfc9112.html#chunked.extension
Equations
Instances For
A validated chunk extension name that ensures all characters conform to HTTP standards per RFC 9112 §7.1.1. Extension names appear in chunked transfer encoding as key-value metadata.
Reference: https://httpwg.org/specs/rfc9112.html#chunked.extension
- value : String
The extension name string.
- isValidExtensionName : IsValidExtensionName self.value
The proof that it's a valid extension name.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Std.Http.Chunk.instBEqExtensionName.beq x✝¹ x✝ = false
Instances For
Equations
Equations
- Std.Http.Chunk.instHashableExtensionName = { hash := fun (x : Std.Http.Chunk.ExtensionName) => hash x.value }
Equations
- Std.Http.Chunk.instInhabitedExtensionName = { default := { value := "_", isValidExtensionName := Std.Http.Chunk.instInhabitedExtensionName._proof_1 } }
Equations
- Std.Http.Chunk.instToStringExtensionName = { toString := fun (name : Std.Http.Chunk.ExtensionName) => name.value }
Attempts to create an ExtensionName from a String, returning none if the string contains
invalid characters or is empty.
Equations
- Std.Http.Chunk.ExtensionName.ofString? s = if h : Std.Http.Chunk.IsValidExtensionName s then some { value := s, isValidExtensionName := h } else none
Instances For
Creates an ExtensionName from a string, panicking with an error message if the string contains
invalid characters or is empty.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A proposition asserting that s is a valid extension value, meaning every character passes
Char.quotedStringChar (i.e. is qdtext or a valid quoted-pair payload).
Reference: https://httpwg.org/specs/rfc9112.html#chunked.extension
Equations
Instances For
A validated chunk extension value that ensures all characters conform to HTTP standards per RFC 9112 §7.1.1. Extension values appear in chunked transfer encoding as metadata associated with extension names.
Note: UTF-8 encoding is not supported. The quoting mechanism is strict and only permits escaping specific values. Additionally, the library does not support obs-text, which means certain UTF-8 characters or values outside of token, qdtext, and the limited set of escapable characters cannot be encoded.
Reference: https://httpwg.org/specs/rfc9112.html#chunked.extension
- value : String
The extension value string.
- isValidExtensionValue : IsValidExtensionValue self.value
The proof that it's a valid extension value.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Std.Http.Chunk.instBEqExtensionValue.beq x✝¹ x✝ = false
Instances For
Equations
Equations
- Std.Http.Chunk.ExtensionValue.instInhabited = { default := { value := "", isValidExtensionValue := Std.Http.Chunk.ExtensionValue.instInhabited._proof_1 } }
Equations
- Std.Http.Chunk.ExtensionValue.instToString = { toString := fun (v : Std.Http.Chunk.ExtensionValue) => v.value }
Quotes an extension value if it contains non-token characters, otherwise returns it as-is.
Equations
Instances For
Attempts to create an ExtensionValue from a String, returning none if the string contains
characters that cannot be encoded as an HTTP quoted-string.
Equations
- Std.Http.Chunk.ExtensionValue.ofString? s = if h : Std.Http.Chunk.IsValidExtensionValue s then some { value := s, isValidExtensionValue := h } else none
Instances For
Creates an ExtensionValue from a string, panicking with an error message if the string contains
characters that cannot be encoded as an HTTP quoted-string.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Represents a chunk of data with optional extensions (key-value pairs).
Reference: https://httpwg.org/specs/rfc9112.html#rfc.section.7.1
- data : ByteArray
The byte data contained in this chunk.
- extensions : Array (ExtensionName × Option ExtensionValue)
Optional metadata associated with this chunk as key-value pairs. Keys are validated
Chunk.ExtensionNamevalues, values are optional strings.
Instances For
Equations
Instances For
An empty chunk with no data and no extensions.
Equations
- Std.Http.Chunk.empty = { data := ByteArray.empty }
Instances For
Creates a simple chunk without extensions.
Equations
- Std.Http.Chunk.ofByteArray data = { data := data }
Instances For
Adds an extension to a chunk.
Equations
Instances For
Interprets the chunk data as a UTF-8 encoded string.
Equations
- chunk.toString? = String.fromUTF8? chunk.data
Instances For
Equations
- One or more equations did not get rendered due to their size.
Trailer headers sent after the final chunk in HTTP/1.1 chunked transfer encoding. Per RFC 9112 §7.1.2, trailers allow the sender to include additional metadata after the message body, such as message integrity checks or digital signatures.
- headers : Headers
The trailer header fields as key-value pairs.
Instances For
Equations
Equations
- Std.Http.instInhabitedTrailer.default = { headers := default }
Instances For
Creates an empty trailer with no headers.
Equations
- Std.Http.Trailer.empty = { headers := Std.Http.Headers.empty }
Instances For
Inserts a trailer header field.
Instances For
Retrieves the first value for the given trailer header name.
Returns none if absent.
Instances For
Retrieves all values for the given trailer header name.
Returns none if absent.
Instances For
Checks if a trailer header with the given name exists.
Instances For
Converts the trailer headers to a list of key-value pairs.
Instances For
Converts the trailer headers to an array of key-value pairs.
Instances For
Folds over all key-value pairs in the trailer headers.
Instances For
Equations
- One or more equations did not get rendered due to their size.