Documentation

Std.Http.Data.Headers.Basic

Header Typeclass and Common Headers #

This module defines the Header typeclass for typed HTTP headers and some common header parsers.

Reference: https://www.rfc-editor.org/rfc/rfc9110.html#name-representation-data-and-met

class Std.Http.Header (α : Type) :

Typeclass for typed HTTP headers that can be parsed from and serialized to header values.

  • parse : Value → Option α

    Parses a header value into the typed representation.

  • serialize : α → Name × Value

    Serializes the typed representation back to a name-value pair.

Instances

    Appends the field line Name: value\r\n.

    Equations
    Instances For
      @[instance_reducible]
      Equations
      • One or more equations did not get rendered due to their size.

      The Content-Length header, representing the size of the message body in bytes. Parses only valid natural number values.

      Reference: https://www.rfc-editor.org/rfc/rfc9110.html#section-8.6-2

      • length : Nat

        The content length in bytes.

      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Serializes a content length header back to a name-value pair.

          Equations
          Instances For

            Validates the chunked placement rules for the Transfer Encoding header. Returns false if the encoding list violates the constraints.

            Reference: https://www.rfc-editor.org/rfc/rfc9112#section-6.1

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              The Transfer-Encoding header, representing the list of transfer codings applied to the message body.

              Validation rules (RFC 9112 Section 6.1):

              • "chunked" may appear at most once.
              • If "chunked" is present, it must be the last encoding in the list.

              Reference: https://www.rfc-editor.org/rfc/rfc9112#section-6.1

              • codings : Array String

                The ordered list of transfer coding names, lowercased and without their parameters.

              • isValid : Validate self.codings = true

                Proof that the transfer codings satisfy the chunked placement rules.

              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Returns true if the transfer encoding ends with chunked.

                  Equations
                  Instances For

                    Parses a comma-separated list of transfer codings into their lowercased names, without the chunked placement rules of parse.

                    Empty list elements (gzip, , chunked) are skipped (RFC 9110 §5.6.1.2). Transfer parameters (gzip;level=1) are checked and dropped. chunked defines none, so a list in which chunked has one is rejected. A quoted parameter value that contains , or ; is not supported.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Parses the transfer codings of all of a message's Transfer-Encoding field lines, in order, with parseCodings?. The field lines of a list-based field form one list (RFC 9110 §5.3), so Transfer-Encoding: gzip followed by Transfer-Encoding: chunked is gzip, chunked.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Parses a comma-separated list of transfer codings from a header value (parseCodings?), validating chunked placement. Transfer parameters are accepted and dropped.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Classifies a message's Transfer-Encoding field lines by their final coding, which decides how the message is framed (RFC 9112 §6.3): some true when they end in chunked applied once, some false when they end in another coding or list none, and none when they are not lists of transfer codings (parseFieldLines?) or end in a chunked applied more than once.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Serializes a transfer encoding back to a comma-separated header value.

                            Equations
                            Instances For

                              The Connection header, represented as a list of connection option tokens.

                              Reference: https://www.rfc-editor.org/rfc/rfc9110.html#name-connection

                              Instances For
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Checks whether a specific token is present in the Connection header value.

                                  Equations
                                  Instances For

                                    Checks whether the Connection header requests connection close semantics.

                                    Equations
                                    Instances For

                                      Parses a Connection header value into normalized tokens.

                                      Equations
                                      Instances For

                                        Serializes a Connection header back to a comma-separated value.

                                        Equations
                                        Instances For

                                          The Host header.

                                          Represents the authority component of a URI: host [ ":" port ]

                                          parse reads an RFC 3986 host: it decodes percent-encoding and lowercases a name, so Ex%61mple.com and example.com parse to the same Host. A trailing . is kept, so example.com. and example.com stay distinct, as do an omitted port and an explicit default one.

                                          Reference: https://www.rfc-editor.org/rfc/rfc9110.html#name-host-and-authority

                                          • host : URI.Host

                                            Host name (reg-name, IPv4, or IPv6 literal).

                                          • port : URI.Port

                                            Optional port.

                                          Instances For
                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For
                                              Equations
                                              Instances For

                                                Parses a Host header value.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For

                                                  Serializes a Host header back to a name and a value.

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For

                                                    The Expect header.

                                                    Represents an expectation token. The only standardized expectation is 100-continue.

                                                    Reference: https://www.rfc-editor.org/rfc/rfc9110.html#name-expect

                                                      Instances For

                                                        Parses an Expect header.

                                                        Succeeds only if the value is exactly 100-continue (case-insensitive, trimmed).

                                                        Equations
                                                        Instances For