HTTP Character Predicates #
This module provides shared character validation predicates used across the HTTP library.
All predicates in this module are ASCII-only by design (isAscii c where applicable), and
intentionally exclude obs-text and all non-ASCII code points.
Checks if a character is ASCII (Unicode code point < 128).
Equations
- Std.Http.Internal.Char.isAscii c = decide (c.toNat < 128)
Instances For
Checks if a byte represents an ASCII character (value < 128).
Equations
- Std.Http.Internal.Char.isAsciiByte c = decide (c < 128)
Instances For
Checks if a byte is an alphabetic character (a-z or A-Z).
Equations
Instances For
tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
/ "+" / "-" / "." / "^" / "_" / "" / "|" / "~" / DIGIT / ALPHA ; Visible token characters used to build token`.
Equations
- Std.Http.Internal.Char.tchar '!' = (true || '!'.isDigit || '!'.isAlpha)
- Std.Http.Internal.Char.tchar '#' = (true || '#'.isDigit || '#'.isAlpha)
- Std.Http.Internal.Char.tchar '$' = (true || '$'.isDigit || '$'.isAlpha)
- Std.Http.Internal.Char.tchar '%' = (true || '%'.isDigit || '%'.isAlpha)
- Std.Http.Internal.Char.tchar '&' = (true || '&'.isDigit || '&'.isAlpha)
- Std.Http.Internal.Char.tchar '\'' = (true || '\''.isDigit || '\''.isAlpha)
- Std.Http.Internal.Char.tchar '*' = (true || '*'.isDigit || '*'.isAlpha)
- Std.Http.Internal.Char.tchar '+' = (true || '+'.isDigit || '+'.isAlpha)
- Std.Http.Internal.Char.tchar '-' = (true || '-'.isDigit || '-'.isAlpha)
- Std.Http.Internal.Char.tchar '.' = (true || '.'.isDigit || '.'.isAlpha)
- Std.Http.Internal.Char.tchar '^' = (true || '^'.isDigit || '^'.isAlpha)
- Std.Http.Internal.Char.tchar '_' = (true || '_'.isDigit || '_'.isAlpha)
- Std.Http.Internal.Char.tchar '`' = (true || '`'.isDigit || '`'.isAlpha)
- Std.Http.Internal.Char.tchar '|' = (true || '|'.isDigit || '|'.isAlpha)
- Std.Http.Internal.Char.tchar '~' = (true || '~'.isDigit || '~'.isAlpha)
- Std.Http.Internal.Char.tchar c = (false || c.isDigit || c.isAlpha)
Instances For
vchar = %x21-7E ; Visible (printing) ASCII characters.
Instances For
qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E ; ASCII-only variant (no obs-text).
Equations
- Std.Http.Internal.Char.qdtext '\t' = (true || decide ('#' ≤ '\t' ∧ '\t' ≤ '[') || decide (']' ≤ '\t' ∧ '\t' ≤ '~'))
- Std.Http.Internal.Char.qdtext ' ' = (true || decide ('#' ≤ ' ' ∧ ' ' ≤ '[') || decide (']' ≤ ' ' ∧ ' ' ≤ '~'))
- Std.Http.Internal.Char.qdtext '!' = (true || decide ('#' ≤ '!' ∧ '!' ≤ '[') || decide (']' ≤ '!' ∧ '!' ≤ '~'))
- Std.Http.Internal.Char.qdtext c = (false || decide ('#' ≤ c ∧ c ≤ '[') || decide (']' ≤ c ∧ c ≤ '~'))
Instances For
quoted-pair = "\" ( HTAB / SP / VCHAR ) ; ASCII-only variant (no obs-text).
Equations
Instances For
quoted-string body character class: ( qdtext / quoted-pair payload ) in ASCII-only mode.
Equations
Instances For
field-vchar = VCHAR ; ASCII-only variant (no obs-text).
Instances For
field-content character class: field-vchar / SP / HTAB ; ASCII-only variant (no obs-text).
Equations
Instances For
ctext = HTAB / SP / %x21-27 / %x2A-5B / %x5D-7E ; ASCII-only variant (no obs-text).
Equations
- Std.Http.Internal.Char.ctext '\t' = (true || decide ('!' ≤ '\t' ∧ '\t' ≤ '\'') || decide ('*' ≤ '\t' ∧ '\t' ≤ '[') || decide (']' ≤ '\t' ∧ '\t' ≤ '~'))
- Std.Http.Internal.Char.ctext ' ' = (true || decide ('!' ≤ ' ' ∧ ' ' ≤ '\'') || decide ('*' ≤ ' ' ∧ ' ' ≤ '[') || decide (']' ≤ ' ' ∧ ' ' ≤ '~'))
- Std.Http.Internal.Char.ctext c = (false || decide ('!' ≤ c ∧ c ≤ '\'') || decide ('*' ≤ c ∧ c ≤ '[') || decide (']' ≤ c ∧ c ≤ '~'))
Instances For
OWS = *( SP / HTAB ) (character class only)
Equations
Instances For
BWS = OWS (character class alias)
Equations
Instances For
reason-phrase character class: HTAB / SP / VCHAR ; ASCII-only variant (no obs-text).
Reference: https://httpwg.org/specs/rfc9110.html#reason.phrase
Equations
Instances For
Checks if a character is a hexadecimal digit (0-9, a-f, or A-F).
Equations
- Std.Http.Internal.Char.isHexDigit 'a' = (true || 'a'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'b' = (true || 'b'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'c' = (true || 'c'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'd' = (true || 'd'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'e' = (true || 'e'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'f' = (true || 'f'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'A' = (true || 'A'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'B' = (true || 'B'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'C' = (true || 'C'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'D' = (true || 'D'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'E' = (true || 'E'.isDigit)
- Std.Http.Internal.Char.isHexDigit 'F' = (true || 'F'.isDigit)
- Std.Http.Internal.Char.isHexDigit c = (false || c.isDigit)
Instances For
Checks if a byte is a hexadecimal digit (0-9, a-f, or A-F).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks if a byte is an alphanumeric digit (0-9, a-z, or A-Z).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks whether c is an ASCII alphanumeric character.
Equations
Instances For
Checks if a character is valid after the first character of a URI scheme.
Valid characters are ASCII alphanumeric, +, -, and ..
Equations
- Std.Http.Internal.Char.isValidSchemeChar '+' = (Std.Http.Internal.Char.isAsciiAlphaNumChar '+' || true)
- Std.Http.Internal.Char.isValidSchemeChar '-' = (Std.Http.Internal.Char.isAsciiAlphaNumChar '-' || true)
- Std.Http.Internal.Char.isValidSchemeChar '.' = (Std.Http.Internal.Char.isAsciiAlphaNumChar '.' || true)
- Std.Http.Internal.Char.isValidSchemeChar c = (Std.Http.Internal.Char.isAsciiAlphaNumChar c || false)
Instances For
Checks if a character is valid for use in a domain name. Valid characters are ASCII alphanumeric, hyphens, and dots.
Equations
- Std.Http.Internal.Char.isValidDomainNameChar '-' = (Std.Http.Internal.Char.isAsciiAlphaNumChar '-' || true)
- Std.Http.Internal.Char.isValidDomainNameChar '.' = (Std.Http.Internal.Char.isAsciiAlphaNumChar '.' || true)
- Std.Http.Internal.Char.isValidDomainNameChar c = (Std.Http.Internal.Char.isAsciiAlphaNumChar c || false)
Instances For
Checks if a byte is an unreserved character according to RFC 3986. Unreserved characters are: alphanumeric, hyphen, period, underscore, and tilde.
Equations
Instances For
Checks if a byte is a sub-delimiter character according to RFC 3986.
Sub-delimiters are: !, $, &, ', (, ), *, +, ,, ;, =.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks if a byte is a valid path character (pchar) according to RFC 3986.
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
Note: The percent-encoding (pct-encoded) is handled separately by isEncodedChar,
so this predicate only covers the non-percent characters.
Equations
- Std.Http.Internal.Char.isPChar c = (Std.Http.Internal.Char.isUnreserved c || Std.Http.Internal.Char.isSubDelims c || decide (c = ':'.toUInt8) || decide (c = '@'.toUInt8))
Instances For
Checks if a byte is a valid character in a URI query component according to RFC 3986.
query = *( pchar / "/" / "?" )
Equations
Instances For
Checks if a byte is a valid character in a URI fragment component according to RFC 3986.
fragment = *( pchar / "/" / "?" )
Equations
Instances For
Checks if a byte is a valid character in a URI userinfo component according to RFC 3986.
userinfo = *( unreserved/ sub-delims / ":" )
Note: It avoids the pct-encoded of the original grammar because it is used with Encoding.lean
that provides it.
Equations
Instances For
Checks if a byte is a valid character in a URI query component,
excluding the typical key/value separators & and =.
Inspired by query = *( pchar / "/" / "?" ) from RFC 3986,
but disallows & and = so they can be treated as structural separators.