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
# The HTTP request method, such as “GET” or “POST”. This cannot ever be an empty string, and so is always required.
48
+
# The HTTP request method, such as "GET" or "POST". This cannot ever be an empty string, and so is always required.
42
49
CGI::REQUEST_METHOD=>request.method,
43
50
44
-
# The initial portion of the request URL's “path” that corresponds to the application object, so that the application knows its virtual “location”. This may be an empty string, if the application corresponds to the “root” of the server.
51
+
# The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server.
45
52
CGI::SCRIPT_NAME=>"",
46
53
47
-
# The remainder of the request URL's “path”, designating the virtual “location” of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This value may be percent-encoded when originating from a URL.
54
+
# The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This value may be percent-encoded when originating from a URL.
48
55
CGI::PATH_INFO=>request_path,
49
56
CGI::REQUEST_PATH=>request_path,
50
57
CGI::REQUEST_URI=>request.path,
@@ -75,11 +82,27 @@ def make_environment(request)
75
82
# Build a rack `env` from the incoming request and apply it to the rack middleware.
76
83
#
77
84
# @parameter request [Protocol::HTTP::Request] The incoming request.
85
+
# @returns [Protocol::HTTP::Response] The HTTP response.
86
+
# @raises [ArgumentError] If the status is not an integer or headers are nil.
78
87
defcall(request)
79
88
env=self.make_environment(request)
80
89
81
90
status,headers,body=@app.call(env)
82
91
92
+
ifstatus
93
+
status=status.to_i
94
+
else
95
+
raiseArgumentError,"Status must be an integer!"
96
+
end
97
+
98
+
unlessheaders
99
+
raiseArgumentError,"Headers must not be nil!"
100
+
end
101
+
102
+
# unless body.respond_to?(:each)
103
+
# raise ArgumentError, "Body must respond to #each!"
104
+
# end
105
+
83
106
headers,meta=self.wrap_headers(headers)
84
107
85
108
# Rack 2 spec does not allow only partial hijacking.
@@ -96,8 +119,11 @@ def call(request)
96
119
returnfailure_response(exception)
97
120
end
98
121
99
-
# Process the rack response headers into into a {Protocol::HTTP::Headers} instance, along with any extra `rack.` metadata.
100
-
# @returns [Tuple(Protocol::HTTP::Headers, Hash)]
122
+
# Process the rack response headers into a {Protocol::HTTP::Headers} instance, along with any extra `rack.` metadata.
123
+
# Headers with newline-separated values are split into multiple headers.
124
+
#
125
+
# @parameter fields [Hash] The raw response headers.
126
+
# @returns [Tuple(Protocol::HTTP::Headers, Hash)] The processed headers and metadata.
101
127
defwrap_headers(fields)
102
128
headers= ::Protocol::HTTP::Headers.new
103
129
meta={}
@@ -119,6 +145,12 @@ def wrap_headers(fields)
119
145
returnheaders,meta
120
146
end
121
147
148
+
# Convert a {Protocol::HTTP::Response} into a Rack 2 response tuple.
149
+
# Handles protocol upgrades and streaming responses.
150
+
#
151
+
# @parameter env [Hash] The rack environment.
152
+
# @parameter response [Protocol::HTTP::Response] The HTTP response.
0 commit comments