Documentation

Std.Http.Protocol.H1.Reader

HTTP/1.1 Reader #

This module defines the reader state machine for parsing incoming HTTP/1.1 messages. It tracks the parsing state including start line, headers, and body handling for both fixed-length and chunked transfer encodings.

The body-framing sub-state of the Reader state machine.

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

      The state of the Reader state machine.

      • needStartLine {dir : Direction} : State dir

        Initial state waiting for HTTP start line.

      • needHeader {dir : Direction} : NatState dir

        State waiting for HTTP headers, tracking number of headers parsed.

      • readBody {dir : Direction} : BodyStateState dir

        Unified body-reading state.

      • continue {dir : Direction} : State dirState dir

        Paused waiting for a canContinue decision, carrying the next state.

      • pending {dir : Direction} : State dir

        State waiting to be able to read new data.

      • complete {dir : Direction} : State dir

        State that it completed a single request or response and can go to the next one

      • closed {dir : Direction} : State dir

        State that it has completed and cannot process more data.

      • failed {dir : Direction} (error : Error) : State dir

        The input is malformed.

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

          Manages the reading state of the HTTP parsing and processing machine.

          • state : State dir

            The current state of the machine.

          • The input byte array.

          • messageHead : Message.Head dir

            The incoming message head.

          • messageCount : Nat

            Count of messages that this connection has already parsed.

          • bodyBytesRead : Nat

            Number of body bytes read for the current message.

          • headerBytesRead : Nat

            Number of header bytes accumulated for the current message. Counts name + value bytes plus 4 bytes per line for : and \r\n.

          • noMoreInput : Bool

            Set when no further input bytes will arrive (the remote end has closed the connection).

          Instances For
            @[inline]

            Checks if the reader is in a closed state and cannot process more messages.

            Equations
            Instances For
              @[inline]

              Checks if the reader has completed parsing the current message.

              Equations
              Instances For
                @[inline]

                Checks if the reader has encountered an error.

                Equations
                Instances For
                  @[inline]
                  def Std.Http.Protocol.H1.Reader.feed {dir : Direction} (data : ByteArray) (reader : Reader dir) :
                  Reader dir

                  Feeds new data into the reader's input buffer. If the current input is exhausted, replaces it; otherwise compacts the buffer by discarding already-parsed bytes before appending.

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

                    Replaces the reader's input iterator with a new one.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      @[inline]
                      def Std.Http.Protocol.H1.Reader.setMessageHead {dir : Direction} (messageHead : Message.Head dir) (reader : Reader dir) :
                      Reader dir

                      Updates the message head being constructed.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[inline]
                        def Std.Http.Protocol.H1.Reader.addHeader {dir : Direction} (name : Header.Name) (value : Header.Value) (reader : Reader dir) :
                        Reader dir

                        Adds a header to the current message head.

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

                          Closes the reader, transitioning to the closed state.

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

                            Marks the current message as complete and prepares for the next message.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              @[inline]
                              def Std.Http.Protocol.H1.Reader.fail {dir : Direction} (error : Error) (reader : Reader dir) :
                              Reader dir

                              Transitions the reader to a failed state with the given error.

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

                                Resets the reader to parse a new message on the same connection.

                                Equations
                                Instances For
                                  @[inline]

                                  Checks if more input is needed to continue parsing.

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

                                    Returns the current parse error if the reader has failed.

                                    Equations
                                    Instances For
                                      @[inline]

                                      Gets the number of bytes remaining in the input buffer.

                                      Equations
                                      Instances For
                                        @[inline]
                                        def Std.Http.Protocol.H1.Reader.advance {dir : Direction} (n : Nat) (reader : Reader dir) :
                                        Reader dir

                                        Advances the input iterator by n bytes.

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

                                          Transitions to the state for reading headers.

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

                                            Adds body bytes parsed for the current message.

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

                                              Adds header bytes accumulated for the current message.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                @[inline]
                                                def Std.Http.Protocol.H1.Reader.startFixedBody {dir : Direction} (size : Nat) (reader : Reader dir) :
                                                Reader dir

                                                Transitions to the state for reading a fixed-length body.

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

                                                  Transitions to the state for reading chunked transfer encoding.

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

                                                    Marks that no more input will be provided (connection closed).

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

                                                      Checks if the connection should be kept alive for the next message.

                                                      Equations
                                                      Instances For