Class: Zapp::HTTPContext::Request
- Inherits:
-
Object
- Object
- Zapp::HTTPContext::Request
- Defined in:
- lib/zapp/http_context/request.rb
Overview
Represents an HTTP Request to be processed by a worker
Constant Summary collapse
- PARSER_THREAD_HASH_KEY =
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
"PUMA_PARSER_INSTANCE"
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
-
#initialize(socket:) ⇒ Request
constructor
A new instance of Request.
- #parser ⇒ Object
Constructor Details
#initialize(socket:) ⇒ Request
Returns a new instance of Request.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zapp/http_context/request.rb', line 13 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 |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/zapp/http_context/request.rb', line 7 def body @body end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/zapp/http_context/request.rb', line 7 def data @data end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
7 8 9 |
# File 'lib/zapp/http_context/request.rb', line 7 def raw @raw end |
Instance Method Details
#parser ⇒ Object
25 26 27 |
# File 'lib/zapp/http_context/request.rb', line 25 def parser Thread.current[PARSER_THREAD_HASH_KEY] ||= Puma::HttpParser.new end |