You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Console.error(self,"Error occurred during request processing:",error)
151
151
152
-
# Close the response body if it exists and supports closing.
152
+
# Close the response body if it exists and supports closing:
153
153
body&.closeifbody.respond_to?(:close)
154
154
155
-
# Invoke `rack.response_finished` callbacks in reverse order of registration.
156
-
# This ensures that callbacks registered later are invoked first, matching the Rack specification.
155
+
# Invoke `rack.response_finished` callbacks in reverse order of registration. This ensures that callbacks registered later are invoked first, matching the Rack specification.
# If a callback raises an exception, log it but continue invoking other callbacks.
162
-
# The Rack specification states that callbacks should not raise exceptions, but we handle
163
-
# this gracefully to prevent one misbehaving callback from breaking others.
160
+
# If a callback raises an exception, log it but continue invoking other callbacks. The Rack specification states that callbacks should not raise exceptions, but we handle this gracefully to prevent one misbehaving callback from breaking others.
164
161
Console.error(self,"Error occurred during response finished callback:",callback_error)
165
162
end
166
163
end
167
164
168
165
returnfailure_response(error)
169
166
end
170
167
171
-
# Build a rack `env` from the incoming request and apply it to the rack middleware.
168
+
# Build a Rack `env` from the incoming request and apply it to the Rack middleware.
172
169
#
173
170
# @parameter request [Protocol::HTTP::Request] The incoming request.
174
171
# @returns [Protocol::HTTP::Response] The HTTP response.
# Invoke callbacks in reverse order of registration, as specified by the Rack specification.
119
+
# Callbacks are invoked in reverse order of registration, as required by the Rack specification:
120
120
response_finished.reverse_eachdo |callback|
121
121
begin
122
122
callback.call(env,status,headers,error)
123
123
rescue=>callback_error
124
-
# If a callback raises an exception, log it but continue invoking other callbacks.
125
-
# The Rack specification states that callbacks should not raise exceptions, but we handle
126
-
# this gracefully to prevent one misbehaving callback from breaking others.
124
+
# If a callback raises an exception, log it but continue invoking other callbacks. The Rack specification states that callbacks should not raise exceptions, but we handle this gracefully to prevent one misbehaving callback from breaking others:
127
125
Console.error(self,"Error occurred during response finished callback:",callback_error)
Copy file name to clipboardExpand all lines: lib/protocol/rack/request.rb
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,8 @@
12
12
moduleProtocol
13
13
moduleRack
14
14
# A Rack-compatible HTTP request wrapper.
15
-
# This class provides a bridge between Rack's environment hash and Protocol::HTTP::Request.
16
-
# It handles conversion of Rack environment variables to HTTP request properties.
15
+
#
16
+
# This class provides a bridge between Rack's environment hash and {Protocol::HTTP::Request}. It handles conversion of Rack environment variables to HTTP request properties.
17
17
classRequest < ::Protocol::HTTP::Request
18
18
# Get or create a Request instance for the given Rack environment.
19
19
# The request is cached in the environment to avoid creating multiple instances.
@@ -43,7 +43,8 @@ def initialize(env)
43
43
end
44
44
45
45
# Extract the protocol list from the Rack environment.
46
-
# Checks both `rack.protocol` and `HTTP_UPGRADE` headers.
46
+
#
47
+
# Checks both `rack.protocol` and {CGI::HTTP_UPGRADE} headers.
47
48
#
48
49
# @parameter env [Hash] The Rack environment hash.
49
50
# @returns [Array(String) | Nil] The list of protocols or `nil` if none specified.
0 commit comments