Sha256: 5cfed10c722c3b24abf27cddf12b72e705a6e55942903b30fd8baa65a696fb53

Contents?: true

Size: 686 Bytes

Versions: 2

Compression:

Stored size: 686 Bytes

Contents

# frozen_string_literal: true

module Zapp
  module HTTPContext
    # Represents an HTTP Request to be processed by a worker
    class Request
      attr_reader(:raw, :data, :body)

      def initialize(socket:)
        raise(EOFError) if socket.eof?

        # Max Request size of 8KB TODO: Make a config value for this setting
        @raw = socket.readpartial(8192)
        @data = {}
      end

      def parse!(parser: Puma::HttpParser.new)
        parser.execute(data, raw, 0)
        @body = Zapp::InputStream.new(string: parser.body)
        parser.reset
      end

      def parsed?
        body.is_a?(Zapp::InputStream) && !data.nil? && data != {}
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zapp-0.1.1 lib/zapp/http_context/request.rb
zapp-0.1.0 lib/zapp/http_context/request.rb