raptor 0.10.0 → 0.12.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/.buildkite/pipeline.yml +100 -0
- data/CHANGELOG.md +21 -0
- data/README.md +47 -31
- data/docs/raptor-vs-puma.md +104 -75
- data/ext/raptor_bpf/reuseport_select.bpf.c +3 -2
- data/ext/raptor_http/raptor_http.c +28 -3
- data/ext/raptor_native/raptor_native.c +16 -2
- data/lib/raptor/cli.rb +11 -2
- data/lib/raptor/cluster.rb +368 -29
- data/lib/raptor/http.rb +1 -0
- data/lib/raptor/http1.rb +71 -24
- data/lib/raptor/http2.rb +46 -3
- data/lib/raptor/reuseport_bpf.rb +13 -0
- data/lib/raptor/server.rb +14 -6
- data/lib/raptor/version.rb +1 -1
- data/sig/generated/raptor/cluster.rbs +173 -34
- data/sig/generated/raptor/http.rbs +2 -0
- data/sig/generated/raptor/http1.rbs +18 -5
- data/sig/generated/raptor/http2.rbs +16 -0
- data/sig/generated/raptor/reuseport_bpf.rbs +9 -0
- data/sig/generated/raptor/server.rbs +10 -4
- metadata +1 -1
|
@@ -64,6 +64,18 @@ module Raptor
|
|
|
64
64
|
|
|
65
65
|
ILLEGAL_HEADER_VALUE_REGEX: ::Regexp
|
|
66
66
|
|
|
67
|
+
CHUNK_SIZE_REGEX: ::Regexp
|
|
68
|
+
|
|
69
|
+
# Returns true when an HTTP/1.1 request lacks a valid `Host` header per
|
|
70
|
+
# RFC 9112 section 3.2, where a valid value is a non-empty single-value
|
|
71
|
+
# line.
|
|
72
|
+
#
|
|
73
|
+
# @param env [Hash] the Rack environment after header parsing
|
|
74
|
+
# @return [Boolean]
|
|
75
|
+
#
|
|
76
|
+
# @rbs (Hash[String, untyped] env) -> bool
|
|
77
|
+
def self.invalid_host?: (Hash[String, untyped] env) -> bool
|
|
78
|
+
|
|
67
79
|
# Returns true when the message framing shows a request-smuggling vector
|
|
68
80
|
# per RFC 9112 section 6.3: a `Transfer-Encoding` where `chunked` is
|
|
69
81
|
# missing, not the final encoding, or duplicated; a `Transfer-Encoding`
|
|
@@ -79,9 +91,10 @@ module Raptor
|
|
|
79
91
|
# Decodes a chunked transfer-encoded body buffer.
|
|
80
92
|
#
|
|
81
93
|
# Returns the decoded bytes and a state symbol: `:complete` when the
|
|
82
|
-
# terminating zero-length chunk
|
|
83
|
-
# size would exceed `max_size`, `:malformed`
|
|
84
|
-
#
|
|
94
|
+
# terminating zero-length chunk and trailer section were fully consumed,
|
|
95
|
+
# `:too_large` when the decoded size would exceed `max_size`, `:malformed`
|
|
96
|
+
# when a chunk-size line is not valid hex or chunk framing overhead exceeds
|
|
97
|
+
# `MAX_CHUNK_OVERHEAD`, or `:incomplete` otherwise.
|
|
85
98
|
#
|
|
86
99
|
# @param buffer [String] the raw body buffer to decode
|
|
87
100
|
# @param max_size [Integer, nil] maximum decoded body size, or nil for unlimited
|
|
@@ -579,8 +592,8 @@ module Raptor
|
|
|
579
592
|
# @param headers [Hash] normalized response headers
|
|
580
593
|
# @return [String] formatted header lines, each ending with CRLF
|
|
581
594
|
#
|
|
582
|
-
# @rbs (Hash[String, String | Array[String]] headers) ->
|
|
583
|
-
def format_headers: (Hash[String, String | Array[String]] headers) ->
|
|
595
|
+
# @rbs (String result, Hash[String, String | Array[String]] headers) -> void
|
|
596
|
+
def format_headers: (String result, Hash[String, String | Array[String]] headers) -> void
|
|
584
597
|
|
|
585
598
|
# Appends one or more `name: value` header lines to `result`. Newline-
|
|
586
599
|
# separated values are emitted as separate lines; empty values and values
|
|
@@ -145,6 +145,22 @@ module Raptor
|
|
|
145
145
|
|
|
146
146
|
HOP_BY_HOP_HEADERS: untyped
|
|
147
147
|
|
|
148
|
+
REQUEST_PSEUDO_HEADERS: untyped
|
|
149
|
+
|
|
150
|
+
REQUIRED_REQUEST_PSEUDO_HEADERS: untyped
|
|
151
|
+
|
|
152
|
+
# Returns true when a decoded header block violates the HTTP/2 pseudo-header
|
|
153
|
+
# rules from RFC 9113 section 8.3: an unknown pseudo-header, a duplicate
|
|
154
|
+
# pseudo-header, a pseudo-header appearing after any regular header, or a
|
|
155
|
+
# required pseudo-header (`:method`, `:scheme`, `:path`) missing on
|
|
156
|
+
# non-`CONNECT` requests.
|
|
157
|
+
#
|
|
158
|
+
# @param headers [Array<Array(String, String)>] decoded header pairs
|
|
159
|
+
# @return [Boolean]
|
|
160
|
+
#
|
|
161
|
+
# @rbs (Array[[String, String]] headers) -> bool
|
|
162
|
+
def self.invalid_pseudo_headers?: (Array[[ String, String ]] headers) -> bool
|
|
163
|
+
|
|
148
164
|
@initial_settings_frame: String
|
|
149
165
|
|
|
150
166
|
@on_error: ^(Hash[String, untyped]?, Exception) -> void | nil
|
|
@@ -52,5 +52,14 @@ module Raptor
|
|
|
52
52
|
#
|
|
53
53
|
# @rbs (Integer backlog) -> void
|
|
54
54
|
def self.update_load: (Integer backlog) -> void
|
|
55
|
+
|
|
56
|
+
# Marks a worker's slot as unavailable by parking its load at the
|
|
57
|
+
# sentinel maximum so the BPF program's least-loaded pick skips it.
|
|
58
|
+
#
|
|
59
|
+
# @param worker_index [Integer] slot index for the worker to mark
|
|
60
|
+
# @return [void]
|
|
61
|
+
#
|
|
62
|
+
# @rbs (Integer worker_index) -> void
|
|
63
|
+
def self.mark_unavailable: (Integer worker_index) -> void
|
|
55
64
|
end
|
|
56
65
|
end
|
|
@@ -82,11 +82,17 @@ module Raptor
|
|
|
82
82
|
# @rbs () -> Thread
|
|
83
83
|
def run: () -> Thread
|
|
84
84
|
|
|
85
|
-
#
|
|
85
|
+
# Stops the accept loop and, when `drain_accept_queue` is enabled,
|
|
86
|
+
# dispatches every connection already in the kernel accept queue. Leaves
|
|
87
|
+
# the listening sockets open so they can be handed to replacement workers.
|
|
86
88
|
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
89
|
+
# @return [void]
|
|
90
|
+
#
|
|
91
|
+
# @rbs () -> void
|
|
92
|
+
def stop_accepting: () -> void
|
|
93
|
+
|
|
94
|
+
# Gracefully shuts down the server, stopping the accept loop and closing
|
|
95
|
+
# all listening sockets.
|
|
90
96
|
#
|
|
91
97
|
# @return [void]
|
|
92
98
|
#
|