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,6 +82,8 @@ 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
@@ -110,8 +119,11 @@ def call(request)
110
119
returnfailure_response(exception)
111
120
end
112
121
113
-
# Process the rack response headers into into a {Protocol::HTTP::Headers} instance, along with any extra `rack.` metadata.
114
-
# @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.
115
127
defwrap_headers(fields)
116
128
headers= ::Protocol::HTTP::Headers.new
117
129
meta={}
@@ -133,6 +145,12 @@ def wrap_headers(fields)
133
145
returnheaders,meta
134
146
end
135
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.
# The HTTP request method, such as “GET” or “POST”. This cannot ever be an empty string, and so is always required.
64
+
# The HTTP request method, such as "GET" or "POST". This cannot ever be an empty string, and so is always required.
42
65
CGI::REQUEST_METHOD=>request.method,
43
66
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.
67
+
# 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
68
CGI::SCRIPT_NAME=>"",
46
69
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.
70
+
# 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
71
CGI::PATH_INFO=>request_path,
49
72
CGI::REQUEST_PATH=>request_path,
50
73
CGI::REQUEST_URI=>request.path,
@@ -72,8 +95,11 @@ def make_environment(request)
72
95
returnenv
73
96
end
74
97
75
-
# Process the rack response headers into into a {Protocol::HTTP::Headers} instance, along with any extra `rack.` metadata.
76
-
# @returns [Tuple(Protocol::HTTP::Headers, Hash)]
98
+
# Process the rack response headers into a {Protocol::HTTP::Headers} instance, along with any extra `rack.` metadata.
99
+
# Unlike Rack 2, this adapter handles array values directly without splitting on newlines.
100
+
#
101
+
# @parameter fields [Hash] The raw response headers.
102
+
# @returns [Tuple(Protocol::HTTP::Headers, Hash)] The processed headers and metadata.
77
103
defwrap_headers(fields)
78
104
headers= ::Protocol::HTTP::Headers.new
79
105
meta={}
@@ -95,6 +121,13 @@ def wrap_headers(fields)
95
121
returnheaders,meta
96
122
end
97
123
124
+
# Convert a {Protocol::HTTP::Response} into a Rack 3 response tuple.
125
+
# Handles protocol upgrades and streaming responses.
126
+
# Unlike Rack 2, this adapter forces streaming responses by converting the body to a callable.
127
+
#
128
+
# @parameter env [Hash] The rack environment.
129
+
# @parameter response [Protocol::HTTP::Response] The HTTP response.
# The HTTP request method, such as “GET” or “POST”. This cannot ever be an empty string, and so is always required.
40
+
# The HTTP request method, such as "GET" or "POST". This cannot ever be an empty string, and so is always required.
29
41
CGI::REQUEST_METHOD=>request.method,
30
42
31
-
# 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.
43
+
# 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.
32
44
CGI::SCRIPT_NAME=>"",
33
45
34
-
# 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.
46
+
# 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.
0 commit comments