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
Copy file name to clipboardExpand all lines: SPEC.rdoc
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ The remainder of the request URL's "path", designating the virtual "location" of
34
34
35
35
The <tt>PATH_INFO</tt>, if provided, must be a valid request target or an empty string, as defined by {RFC9110}[https://datatracker.ietf.org/doc/html/rfc9110#target.resource].
36
36
* Only <tt>OPTIONS</tt> requests may have <tt>PATH_INFO</tt> set to <tt>*</tt> (asterisk-form).
37
-
* Only <tt>CONNECT</tt> requests may have <tt>PATH_INFO</tt> set to an authority (authority-form). Note that in HTTP/2+, the authority-form is not a valid request target.
37
+
* Only <tt>CONNECT</tt> requests may have <tt>PATH_INFO</tt> set to an authority (authority-form). Note that in <tt>HTTP/2+</tt>, the authority-form is not a valid request target.
38
38
* <tt>CONNECT</tt> and <tt>OPTIONS</tt> requests must not have <tt>PATH_INFO</tt> set to a URI (absolute-form).
39
39
* Otherwise, <tt>PATH_INFO</tt> must start with a <tt>/</tt> and must not include a fragment part starting with <tt>#</tt> (origin-form).
40
40
@@ -88,7 +88,7 @@ The URL scheme, which must be one of <tt>http</tt>, <tt>https</tt>, <tt>ws</tt>
88
88
89
89
==== <tt>rack.protocol</tt>
90
90
91
-
An optional +Array+ of +String+ values, containing the protocols advertised by the client in the <tt>upgrade</tt> header (HTTP/1) or the <tt>:protocol</tt> pseudo-header (HTTP/2+).
91
+
An optional +Array+ of +String+ values, containing the protocols advertised by the client in the <tt>upgrade</tt> header (<tt>HTTP/1</tt>) or the <tt>:protocol</tt> pseudo-header (<tt>HTTP/2+</tt>).
92
92
93
93
==== <tt>rack.session</tt>
94
94
@@ -167,13 +167,13 @@ The error stream must respond to +puts+, +write+ and +flush+:
167
167
168
168
The hijacking interfaces provides a means for an application to take control of the HTTP connection. There are two distinct hijack interfaces: full hijacking where the application takes over the raw connection, and partial hijacking where the application takes over just the response body stream. In both cases, the application is responsible for closing the hijacked stream.
169
169
170
-
Full hijacking only works with HTTP/1. Partial hijacking is functionally equivalent to streaming bodies, and is still optionally supported for backwards compatibility with older Rack versions.
170
+
Full hijacking only works with <tt>HTTP/1</tt>. Partial hijacking is functionally equivalent to streaming bodies, and is still optionally supported for backwards compatibility with older Rack versions.
171
171
172
172
==== Full Hijack
173
173
174
-
Full hijack is used to completely take over an HTTP/1 connection. It occurs before any headers are written and causes the server to ignore any response generated by the application. It is intended to be used when applications need access to the raw HTTP/1 connection.
174
+
Full hijack is used to completely take over an <tt>HTTP/1</tt> connection. It occurs before any headers are written and causes the server to ignore any response generated by the application. It is intended to be used when applications need access to the raw <tt>HTTP/1</tt> connection.
175
175
176
-
If <tt>rack.hijack</tt> is present in +env+, it must respond to +call+ and return an +IO+ instance which can be used to read and write to the underlying connection using HTTP/1 semantics and formatting.
176
+
If <tt>rack.hijack</tt> is present in +env+, it must respond to +call+ and return an +IO+ instance which can be used to read and write to the underlying connection using <tt>HTTP/1</tt> semantics and formatting.
177
177
178
178
==== Partial Hijack
179
179
@@ -205,23 +205,23 @@ This is an HTTP status. It must be an Integer greater than or equal to 100.
205
205
The headers must be a unfrozen +Hash+. The header keys must be +String+ objects. Special headers starting <tt>rack.</tt> are for communicating with the server, and must not be sent back to the client.
206
206
207
207
* The headers must not contain a <tt>"status"</tt> key.
208
-
* Header keys must conform to RFC7230 token specification, i.e. cannot contain non-printable ASCII, DQUOTE or <tt>(),/:;<=>?@[\]{}</tt>.
208
+
* Header keys must conform to {RFC7230}[https://tools.ietf.org/html/rfc7230] token specification, i.e. cannot contain non-printable ASCII, DQUOTE or <tt>(),/:;<=>?@[\]{}</tt>.
209
209
* Header keys must not contain uppercase ASCII characters (A-Z).
210
210
* Header values must be either a +String+ value, or an +Array+ of +String+ values, such that each +String+ value must not contain characters with an ASCII ordinal below 040 (32).
211
211
212
212
==== The <tt>content-type</tt> Header
213
213
214
-
There must not be a <tt>content-type</tt> header key when the status is 1xx, 204, or 304.
214
+
There must not be a <tt>content-type</tt> header key when the status is <tt>1xx</tt>, <tt>204</tt>, or <tt>304</tt>.
215
215
216
216
==== The <tt>content-length</tt> Header
217
217
218
-
There must not be a <tt>content-length</tt> header key when the status is 1xx, 204, or 304.
218
+
There must not be a <tt>content-length</tt> header key when the status is <tt>1xx</tt>, <tt>204</tt>, or <tt>304</tt>.
219
219
220
220
==== The <tt>rack.protocol</tt> Header
221
221
222
222
If the <tt>rack.protocol</tt> header is present, it must be a +String+, and must be one of the values from the <tt>rack.protocol</tt> array from the environment.
223
223
224
-
Setting this value informs the server that it should perform a connection upgrade. In HTTP/1, this is done using the +upgrade+ header. In HTTP/2, this is done by accepting the request.
224
+
Setting this value informs the server that it should perform a connection upgrade. In <tt>HTTP/1</tt>, this is done using the +upgrade+ header. In <tt>HTTP/2</tt>, this is done by accepting the request.
225
225
226
226
=== The Body
227
227
@@ -249,7 +249,7 @@ If the Body responds to +to_ary+, it must return an +Array+ whose contents are i
249
249
250
250
The Streaming Body must respond to +call+. It must only be called once. It must not be called after being closed. It takes a +stream+ argument.
251
251
252
-
The +stream+ argument must respond to: +read+, +write+, <tt><<</tt>, +flush+, +close+, +close_read+, +close_write+, and +closed?+. The semantics of these +IO+ methods must be a best effort match to those of a normal Ruby +IO+ or +Socket+ object, using standard arguments and raising standard exceptions. Servers may simply pass on real +IO+ objects to the Streaming Body. In some cases (e.g. when using <tt>transfer-encoding</tt> or HTTP/2+), the server may need to provide a wrapper that implements the required methods, in order to provide the correct semantics.
252
+
The +stream+ argument must respond to: +read+, +write+, <tt><<</tt>, +flush+, +close+, +close_read+, +close_write+, and +closed?+. The semantics of these +IO+ methods must be a best effort match to those of a normal Ruby +IO+ or +Socket+ object, using standard arguments and raising standard exceptions. Servers may simply pass on real +IO+ objects to the Streaming Body. In some cases (e.g. when using <tt>transfer-encoding</tt> or <tt>HTTP/2+</tt>), the server may need to provide a wrapper that implements the required methods, in order to provide the correct semantics.
Copy file name to clipboardExpand all lines: lib/rack/lint.rb
+16-12Lines changed: 16 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,12 @@ module Rack
10
10
classLint
11
11
# Represents a failure to meet the Rack specification.
12
12
classLintError < RuntimeError;end
13
-
13
+
14
14
# Invoke the application, validating the request and response according to the Rack spec.
15
15
defcall(env=nil)
16
16
Wrapper.new(@app,env).response
17
17
end
18
-
18
+
19
19
# :stopdoc:
20
20
21
21
ALLOWED_SCHEMES=%w(httpshttpwssws).freeze
@@ -55,6 +55,10 @@ def call(env = nil)
55
55
56
56
# N.B. The empty `##` comments creates paragraphs in the output. A trailing "\" is used to escape the newline character, which combines the comments into a single paragraph.
# - Use + for: Ruby types, concepts, method names, class references
61
+
#
58
62
## = Rack Specification
59
63
##
60
64
## This specification aims to formalize the Rack protocol. You can (and should) use +Rack::Lint+ to enforce it. When you develop middleware, be sure to test with +Rack::Lint+ to catch possible violations of this specification.
@@ -213,7 +217,7 @@ def check_environment(env)
213
217
raiseLintError,"Only OPTIONS requests may have PATH_INFO set to '*' (asterisk-form)"
214
218
end
215
219
whenREQUEST_PATH_AUTHORITY_FORM
216
-
## * Only <tt>CONNECT</tt> requests may have <tt>PATH_INFO</tt> set to an authority (authority-form). Note that in HTTP/2+, the authority-form is not a valid request target.
220
+
## * Only <tt>CONNECT</tt> requests may have <tt>PATH_INFO</tt> set to an authority (authority-form). Note that in <tt>HTTP/2+</tt>, the authority-form is not a valid request target.
217
221
unlessenv[REQUEST_METHOD] == CONNECT
218
222
raiseLintError,"Only CONNECT requests may have PATH_INFO set to an authority (authority-form)"
219
223
end
@@ -325,7 +329,7 @@ def check_environment(env)
325
329
##
326
330
## ==== <tt>rack.protocol</tt>
327
331
##
328
-
## An optional +Array+ of +String+ values, containing the protocols advertised by the client in the <tt>upgrade</tt> header (HTTP/1) or the <tt>:protocol</tt> pseudo-header (HTTP/2+).
332
+
## An optional +Array+ of +String+ values, containing the protocols advertised by the client in the <tt>upgrade</tt> header (<tt>HTTP/1</tt>) or the <tt>:protocol</tt> pseudo-header (<tt>HTTP/2+</tt>).
raiseLintError,"rack.protocol must be an Array of Strings"
@@ -610,11 +614,11 @@ def close(*args)
610
614
##
611
615
## The hijacking interfaces provides a means for an application to take control of the HTTP connection. There are two distinct hijack interfaces: full hijacking where the application takes over the raw connection, and partial hijacking where the application takes over just the response body stream. In both cases, the application is responsible for closing the hijacked stream.
612
616
##
613
-
## Full hijacking only works with HTTP/1. Partial hijacking is functionally equivalent to streaming bodies, and is still optionally supported for backwards compatibility with older Rack versions.
617
+
## Full hijacking only works with <tt>HTTP/1</tt>. Partial hijacking is functionally equivalent to streaming bodies, and is still optionally supported for backwards compatibility with older Rack versions.
614
618
##
615
619
## ==== Full Hijack
616
620
##
617
-
## Full hijack is used to completely take over an HTTP/1 connection. It occurs before any headers are written and causes the server to ignore any response generated by the application. It is intended to be used when applications need access to the raw HTTP/1 connection.
621
+
## Full hijack is used to completely take over an <tt>HTTP/1</tt> connection. It occurs before any headers are written and causes the server to ignore any response generated by the application. It is intended to be used when applications need access to the raw <tt>HTTP/1</tt> connection.
618
622
##
619
623
defcheck_hijack(env)
620
624
## If <tt>rack.hijack</tt> is present in +env+, it must respond to +call+ \
@@ -624,7 +628,7 @@ def check_hijack(env)
624
628
env[RACK_HIJACK]=procdo
625
629
io=original_hijack.call
626
630
627
-
## and return an +IO+ instance which can be used to read and write to the underlying connection using HTTP/1 semantics and formatting.
631
+
## and return an +IO+ instance which can be used to read and write to the underlying connection using <tt>HTTP/1</tt> semantics and formatting.
628
632
raiseLintError,"rack.hijack must return an IO instance"unlessio.is_a?(IO)
629
633
630
634
io
@@ -724,7 +728,7 @@ def check_headers(headers)
724
728
##
725
729
## * The headers must not contain a <tt>"status"</tt> key.
726
730
raiseLintError,"headers must not contain status"ifkey == "status"
727
-
## * Header keys must conform to RFC7230 token specification, i.e. cannot contain non-printable ASCII, DQUOTE or <tt>(),/:;<=>?@[\]{}</tt>.
731
+
## * Header keys must conform to {RFC7230}[https://tools.ietf.org/html/rfc7230] token specification, i.e. cannot contain non-printable ASCII, DQUOTE or <tt>(),/:;<=>?@[\]{}</tt>.
## Setting this value informs the server that it should perform a connection upgrade. In HTTP/1, this is done using the +upgrade+ header. In HTTP/2, this is done by accepting the request.
815
+
## Setting this value informs the server that it should perform a connection upgrade. In <tt>HTTP/1</tt>, this is done using the +upgrade+ header. In <tt>HTTP/2</tt>, this is done by accepting the request.
812
816
##
813
817
## === The Body
814
818
##
@@ -937,7 +941,7 @@ def call(stream)
937
941
classStreamWrapper
938
942
extendForwardable
939
943
940
-
## The semantics of these +IO+ methods must be a best effort match to those of a normal Ruby +IO+ or +Socket+ object, using standard arguments and raising standard exceptions. Servers may simply pass on real +IO+ objects to the Streaming Body. In some cases (e.g. when using <tt>transfer-encoding</tt> or HTTP/2+), the server may need to provide a wrapper that implements the required methods, in order to provide the correct semantics.
944
+
## The semantics of these +IO+ methods must be a best effort match to those of a normal Ruby +IO+ or +Socket+ object, using standard arguments and raising standard exceptions. Servers may simply pass on real +IO+ objects to the Streaming Body. In some cases (e.g. when using <tt>transfer-encoding</tt> or <tt>HTTP/2+</tt>), the server may need to provide a wrapper that implements the required methods, in order to provide the correct semantics.
0 commit comments