Sha256: 1d3b6366929bbfc34552f944f8a9baaae2254c1d46c9a616ac16985d9c061d37

Contents?: true

Size: 850 Bytes

Versions: 1

Compression:

Stored size: 850 Bytes

Contents

# frozen_string_literal: true

module LLHttp
  # Wraps an llhttp context for parsing http requests and responses.
  #
  # = Finishing
  #
  # Call `LLHttp::Parser#finish` when processing is complete for the current request or response.
  #
  # = Introspection
  #
  # * `LLHttp::Parser#content_length` returns the content length of the current request.
  # * `LLHttp::Parser#method` returns the method of the current response.
  # * `LLHttp::Parser#keep_alive?` returns `true` if there might be any other messages following the last that was successfuly parsed.
  #
  class Parser
    LLHTTP_TYPES = {both: 0, request: 1, response: 2}.freeze

    attr_reader :type

    def initialize(delegate, type: :both)
      @type, @delegate = type.to_sym, delegate

      llhttp_init(LLHTTP_TYPES.fetch(@type))
    end
  end
end

require_relative "llhttp_ext"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
llhttp-0.0.2 lib/llhttp/parser.rb