hyperion-rb 1.6.2 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4768 -0
- data/README.md +222 -13
- data/ext/hyperion_h2_codec/Cargo.lock +7 -0
- data/ext/hyperion_h2_codec/Cargo.toml +33 -0
- data/ext/hyperion_h2_codec/extconf.rb +73 -0
- data/ext/hyperion_h2_codec/src/frames.rs +140 -0
- data/ext/hyperion_h2_codec/src/hpack/huffman.rs +161 -0
- data/ext/hyperion_h2_codec/src/hpack.rs +457 -0
- data/ext/hyperion_h2_codec/src/lib.rs +296 -0
- data/ext/hyperion_http/extconf.rb +28 -0
- data/ext/hyperion_http/h2_codec_glue.c +408 -0
- data/ext/hyperion_http/page_cache.c +1125 -0
- data/ext/hyperion_http/parser.c +473 -38
- data/ext/hyperion_http/sendfile.c +982 -0
- data/ext/hyperion_http/websocket.c +493 -0
- data/ext/hyperion_io_uring/Cargo.lock +33 -0
- data/ext/hyperion_io_uring/Cargo.toml +34 -0
- data/ext/hyperion_io_uring/extconf.rb +74 -0
- data/ext/hyperion_io_uring/src/lib.rs +316 -0
- data/lib/hyperion/adapter/rack.rb +370 -42
- data/lib/hyperion/admin_listener.rb +207 -0
- data/lib/hyperion/admin_middleware.rb +36 -7
- data/lib/hyperion/cli.rb +310 -11
- data/lib/hyperion/config.rb +440 -14
- data/lib/hyperion/connection.rb +679 -22
- data/lib/hyperion/deprecations.rb +81 -0
- data/lib/hyperion/dispatch_mode.rb +165 -0
- data/lib/hyperion/fiber_local.rb +75 -13
- data/lib/hyperion/h2_admission.rb +77 -0
- data/lib/hyperion/h2_codec.rb +499 -0
- data/lib/hyperion/http/page_cache.rb +122 -0
- data/lib/hyperion/http/sendfile.rb +696 -0
- data/lib/hyperion/http2/native_hpack_adapter.rb +70 -0
- data/lib/hyperion/http2_handler.rb +618 -19
- data/lib/hyperion/io_uring.rb +317 -0
- data/lib/hyperion/lint_wrapper_pool.rb +126 -0
- data/lib/hyperion/master.rb +96 -9
- data/lib/hyperion/metrics/path_templater.rb +68 -0
- data/lib/hyperion/metrics.rb +256 -0
- data/lib/hyperion/prometheus_exporter.rb +150 -0
- data/lib/hyperion/request.rb +13 -0
- data/lib/hyperion/response_writer.rb +477 -16
- data/lib/hyperion/runtime.rb +195 -0
- data/lib/hyperion/server/route_table.rb +179 -0
- data/lib/hyperion/server.rb +519 -55
- data/lib/hyperion/static_preload.rb +133 -0
- data/lib/hyperion/thread_pool.rb +61 -7
- data/lib/hyperion/tls.rb +343 -1
- data/lib/hyperion/version.rb +1 -1
- data/lib/hyperion/websocket/close_codes.rb +71 -0
- data/lib/hyperion/websocket/connection.rb +876 -0
- data/lib/hyperion/websocket/frame.rb +356 -0
- data/lib/hyperion/websocket/handshake.rb +525 -0
- data/lib/hyperion/worker.rb +111 -9
- data/lib/hyperion.rb +137 -3
- metadata +50 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hyperion
|
|
4
|
+
module WebSocket
|
|
5
|
+
# 2.5-A — RFC 6455 §7.4.1 close-code validation.
|
|
6
|
+
#
|
|
7
|
+
# The close-frame status code is a 16-bit unsigned integer at the
|
|
8
|
+
# start of the close-frame payload. Only specific ranges are valid
|
|
9
|
+
# on the wire, and a server that sees an invalid one MUST respond
|
|
10
|
+
# with close 1002 (Protocol Error) per RFC 6455 §7.4 + §7.4.1
|
|
11
|
+
# rather than echoing the bad code back.
|
|
12
|
+
#
|
|
13
|
+
# The IANA-assigned ranges as of RFC 6455:
|
|
14
|
+
#
|
|
15
|
+
# 1000–1003 Defined (Normal, Going Away, Protocol Error,
|
|
16
|
+
# Unsupported Data)
|
|
17
|
+
# 1004 Reserved (no defined meaning — not on wire)
|
|
18
|
+
# 1005 No Status Recv'd (synthetic — MUST NOT appear on wire)
|
|
19
|
+
# 1006 Abnormal Closure (synthetic — MUST NOT appear on wire)
|
|
20
|
+
# 1007–1015 Defined (Invalid Frame Payload, Policy
|
|
21
|
+
# Violation, Message Too Big,
|
|
22
|
+
# Mandatory Ext, Internal Error,
|
|
23
|
+
# Service Restart, Try Again Later,
|
|
24
|
+
# Bad Gateway, TLS handshake)
|
|
25
|
+
# 1016–2999 Reserved for IETF future use (not on wire)
|
|
26
|
+
# 3000–3999 Registered library / framework codes
|
|
27
|
+
# 4000–4999 Application-private codes
|
|
28
|
+
# <1000, >=5000 Invalid (out of any defined range)
|
|
29
|
+
module CloseCodes
|
|
30
|
+
# Whitelisted code ranges that MAY appear on the wire from a peer.
|
|
31
|
+
VALID_RANGES = [
|
|
32
|
+
(1000..1003),
|
|
33
|
+
(1007..1015),
|
|
34
|
+
(3000..3999),
|
|
35
|
+
(4000..4999)
|
|
36
|
+
].freeze
|
|
37
|
+
|
|
38
|
+
# Reserved-for-IETF range — not currently assigned, MUST NOT appear
|
|
39
|
+
# on the wire, MUST be rejected with 1002.
|
|
40
|
+
RESERVED_RANGE = (1016..2999)
|
|
41
|
+
|
|
42
|
+
# Synthetic codes that MUST NOT appear on the wire (RFC 6455 §7.4.1).
|
|
43
|
+
# 1005 = "No Status Received", 1006 = "Abnormal Closure". Both are
|
|
44
|
+
# produced internally by an endpoint when no close code was carried
|
|
45
|
+
# by the close frame, never sent by an endpoint.
|
|
46
|
+
NO_STATUS_ON_WIRE = [1005, 1006].freeze
|
|
47
|
+
|
|
48
|
+
# Validate a peer-supplied close code.
|
|
49
|
+
#
|
|
50
|
+
# @param code [Integer]
|
|
51
|
+
# @return [Symbol] one of:
|
|
52
|
+
# :ok — code is in a valid wire range, accept it
|
|
53
|
+
# :no_status_on_wire — code is 1005 / 1006 (synthetic only)
|
|
54
|
+
# :reserved — code is in 1016–2999 (IETF reserved)
|
|
55
|
+
# :invalid — code is outside every defined range
|
|
56
|
+
def self.validate(code)
|
|
57
|
+
return :no_status_on_wire if NO_STATUS_ON_WIRE.include?(code)
|
|
58
|
+
return :ok if VALID_RANGES.any? { |r| r.cover?(code) }
|
|
59
|
+
return :reserved if RESERVED_RANGE.cover?(code)
|
|
60
|
+
|
|
61
|
+
:invalid
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Convenience predicate — true if the peer's close code violates
|
|
65
|
+
# RFC 6455 §7.4.1 in any way.
|
|
66
|
+
def self.invalid?(code)
|
|
67
|
+
validate(code) != :ok
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|