Class: Hyperion::Server::RouteTable::StaticEntry
- Inherits:
-
Struct
- Object
- Struct
- Hyperion::Server::RouteTable::StaticEntry
- Defined in:
- lib/hyperion/server/route_table.rb
Overview
2.10-D — sentinel result returned by ‘Server.handle_static`’s internal handler. When ‘Connection#serve` sees it, the writer short-circuits to a single `socket.write(buf)` of the pre-built response buffer — no header build, no body iteration. Wrapping the buffer in a small struct (rather than returning the raw String from `handle`) keeps the `[status, headers, body]` shape contract visible while giving the dispatcher a single `is_a?` branch to engage the one-syscall fast path. 2.10-F adds `headers_len` so the C fast path (`PageCache.serve_request`) can write the headers-only prefix for HEAD requests without reparsing the buffer. Defaults to `buffer.bytesize` for back-compat with callers that constructed StaticEntry the 2.10-D way (3 args, no body split) — those entries fall back to writing the whole buffer on HEAD too, which is RFC-correct (HEAD MAY include the body so long as Content-Length matches; the spec only forbids the SERVER from sending body bytes the client didn’t ask for).
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
-
#headers_len ⇒ Object
Returns the value of attribute headers_len.
-
#method ⇒ Object
Returns the value of attribute method.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#call(_request) ⇒ Object
2.10-F — StaticEntry responds to ‘#call` so it can be registered directly in the route table (instead of via a closure wrapping it).
-
#headers_bytesize ⇒ Object
2.10-F — bytes-count of the headers-only prefix.
-
#response_bytes ⇒ Object
Returns the pre-built response bytes ready for one ‘socket.write` call.
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer
60 61 62 |
# File 'lib/hyperion/server/route_table.rb', line 60 def buffer @buffer end |
#headers_len ⇒ Object
Returns the value of attribute headers_len
60 61 62 |
# File 'lib/hyperion/server/route_table.rb', line 60 def headers_len @headers_len end |
#method ⇒ Object
Returns the value of attribute method
60 61 62 |
# File 'lib/hyperion/server/route_table.rb', line 60 def method @method end |
#path ⇒ Object
Returns the value of attribute path
60 61 62 |
# File 'lib/hyperion/server/route_table.rb', line 60 def path @path end |
Instance Method Details
#call(_request) ⇒ Object
2.10-F — StaticEntry responds to ‘#call` so it can be registered directly in the route table (instead of via a closure wrapping it). Returning `self` keeps the `[status, headers, body]` contract: `dispatch_direct!`’s is_a?(StaticEntry) branch handles the wire write. Pre- 2.10-F callers that registered via ‘Server.handle_static` still work — that registration path now stores the entry directly and the route table’s ‘respond_to?(:call)` invariant is preserved.
76 77 78 |
# File 'lib/hyperion/server/route_table.rb', line 76 def call(_request) self end |
#headers_bytesize ⇒ Object
2.10-F — bytes-count of the headers-only prefix. Used by callers that reach the StaticEntry directly (specs, custom writers); the C fast path reads the C-side ‘headers_len` mirror that `PageCache.register_prebuilt` records.
84 85 86 |
# File 'lib/hyperion/server/route_table.rb', line 84 def headers_bytesize headers_len || buffer.bytesize end |
#response_bytes ⇒ Object
Returns the pre-built response bytes ready for one ‘socket.write` call. Always frozen.
63 64 65 |
# File 'lib/hyperion/server/route_table.rb', line 63 def response_bytes buffer end |