Sha256: e248cf638841efdccbf8744ce07ed5ea04b9e2b782e7990c7bf9d3d27aeeb4b1
Contents?: true
Size: 820 Bytes
Versions: 2
Compression:
Stored size: 820 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) # Request parsing is done threaded, but not in separate Ractors. # So we allocate an HTTP parser per thread and assign it to this hash key in Thread.current PARSER_THREAD_HASH_KEY = "PUMA_PARSER_INSTANCE" def initialize(socket:) # Max Request size of 8KB TODO: Make a config value for this setting @raw = socket.readpartial(8192) @data = {} parser.execute(data, raw, 0) @body = Zapp::InputStream.new(string: parser.body) parser.reset end def parser Thread.current[PARSER_THREAD_HASH_KEY] ||= Puma::HttpParser.new end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zapp-0.2.6 | lib/zapp/http_context/request.rb |
zapp-0.2.5 | lib/zapp/http_context/request.rb |