Documentation

Std.Http.Internal.Char

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.

@[inline]

Checks if a character is ASCII (Unicode code point < 128).

Instances For
    @[inline]

    Checks if a byte represents an ASCII character (value < 128).

    Instances For
      @[inline]

      Checks if a byte is a decimal digit (0-9).

      Instances For
        @[inline]

        Checks if a byte is an alphabetic character (a-z or A-Z).

        Instances For
          @[inline]

          tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^" / "_" / "" / "|" / "~" / DIGIT / ALPHA ; Visible token characters used to build token`.

          Instances For
            @[inline]

            vchar = %x21-7E ; Visible (printing) ASCII characters.

            Instances For
              @[inline]

              qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E ; ASCII-only variant (no obs-text).

              Instances For
                @[inline]

                quoted-pair = "\" ( HTAB / SP / VCHAR ) ; ASCII-only variant (no obs-text).

                Instances For
                  @[inline]

                  quoted-string body character class: ( qdtext / quoted-pair payload ) in ASCII-only mode.

                  Instances For
                    @[inline]

                    field-vchar = VCHAR ; ASCII-only variant (no obs-text).

                    Instances For
                      @[inline]

                      field-content character class: field-vchar / SP / HTAB ; ASCII-only variant (no obs-text).

                      Instances For
                        @[inline]

                        ctext = HTAB / SP / %x21-27 / %x2A-5B / %x5D-7E ; ASCII-only variant (no obs-text).

                        Instances For
                          @[inline]

                          etagc = "!" / %x23-7E ; ASCII-only variant (no obs-text).

                          Instances For
                            @[inline]

                            OWS = *( SP / HTAB ) (character class only)

                            Instances For
                              @[inline]

                              BWS = OWS (character class alias)

                              Instances For
                                @[inline]

                                RWS = 1*( SP / HTAB ) (character class is identical to ows)

                                Instances For
                                  @[inline]

                                  obs-text = %x80-FF (and higher Unicode scalar values in this library's Char model).

                                  Instances For
                                    @[inline]

                                    reason-phrase character class: HTAB / SP / VCHAR ; ASCII-only variant (no obs-text).

                                    Reference: https://httpwg.org/specs/rfc9110.html#reason.phrase

                                    Instances For
                                      @[inline]

                                      Checks if a character is a hexadecimal digit (0-9, a-f, or A-F).

                                      Instances For
                                        @[inline]

                                        Checks if a byte is a hexadecimal digit (0-9, a-f, or A-F).

                                        Instances For
                                          @[inline]

                                          Checks if a byte is an alphanumeric digit (0-9, a-z, or A-Z).

                                          Instances For
                                            @[inline]

                                            Checks whether c is an ASCII alphanumeric character.

                                            Instances For
                                              @[inline]

                                              Checks if a character is valid after the first character of a URI scheme. Valid characters are ASCII alphanumeric, +, -, and ..

                                              Instances For
                                                @[inline]

                                                Checks if a character is valid for use in a domain name. Valid characters are ASCII alphanumeric, hyphens, and dots.

                                                Instances For
                                                  @[inline]

                                                  Checks if a byte is an unreserved character according to RFC 3986. Unreserved characters are: alphanumeric, hyphen, period, underscore, and tilde.

                                                  Instances For
                                                    @[inline]

                                                    Checks if a byte is a sub-delimiter character according to RFC 3986. Sub-delimiters are: !, $, &, ', (, ), *, +, ,, ;, =.

                                                    Instances For
                                                      @[inline]

                                                      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.

                                                      Instances For
                                                        @[inline]

                                                        Checks if a byte is a valid character in a URI query component according to RFC 3986. query = *( pchar / "/" / "?" )

                                                        Instances For
                                                          @[inline]

                                                          Checks if a byte is a valid character in a URI fragment component according to RFC 3986. fragment = *( pchar / "/" / "?" )

                                                          Instances For
                                                            @[inline]

                                                            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.

                                                            Instances For
                                                              @[inline]

                                                              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.

                                                              Instances For