Skip to content

Commit b16055b

Browse files
committed
Changes as requested.
1 parent 4edbd8c commit b16055b

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

SPEC.rdoc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The remainder of the request URL's "path", designating the virtual "location" of
3434

3535
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].
3636
* 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 <tt>HTTP/2+</tt>, 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 HTTP/2+, the authority-form is not a valid request target.
3838
* <tt>CONNECT</tt> and <tt>OPTIONS</tt> requests must not have <tt>PATH_INFO</tt> set to a URI (absolute-form).
3939
* Otherwise, <tt>PATH_INFO</tt> must start with a <tt>/</tt> and must not include a fragment part starting with <tt>#</tt> (origin-form).
4040

@@ -88,7 +88,7 @@ The URL scheme, which must be one of <tt>http</tt>, <tt>https</tt>, <tt>ws</tt>
8888

8989
==== <tt>rack.protocol</tt>
9090

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>).
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+).
9292

9393
==== <tt>rack.session</tt>
9494

@@ -167,13 +167,13 @@ The error stream must respond to +puts+, +write+ and +flush+:
167167

168168
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.
169169

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.
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.
171171

172172
==== Full Hijack
173173

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.
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.
175175

176-
If <tt>rack.hijack</tt> is present in +env+, it must respond to +call+ and return an +IO+ object which can be used to read and write to the underlying connection using <tt>HTTP/1</tt> semantics and formatting.
176+
If <tt>rack.hijack</tt> is present in +env+, it must respond to +call+ and return an +IO+ object which can be used to read and write to the underlying connection using HTTP/1 semantics and formatting.
177177

178178
==== Partial Hijack
179179

@@ -205,9 +205,9 @@ This is an HTTP status. It must be an Integer greater than or equal to 100.
205205
The headers must be an unfrozen +Hash+. The header keys must be +String+ values. Special headers starting <tt>rack.</tt> are for communicating with the server, and must not be sent back to the client.
206206

207207
* The headers must not contain a <tt>"status"</tt> key.
208-
* Header keys must conform to {RFC7230}[https://tools.ietf.org/html/rfc7230] token specification, i.e. cannot contain non-printable <tt>ASCII</tt>, <tt>DQUOTE</tt> or <tt>(),/:;<=>?@[\]{}</tt>.
209-
* Header keys must not contain uppercase <tt>ASCII</tt> characters (A-Z).
210-
* Header values must be either a +String+, or an +Array+ of +String+ values, such that each +String+ must not contain characters with an <tt>ASCII</tt> ordinal below <tt>040</tt> (32).
208+
* Header keys must conform to {RFC7230}[https://tools.ietf.org/html/rfc7230] token specification, i.e. cannot contain non-printable ASCII, <tt>DQUOTE</tt> or <tt>(),/:;<=>?@[\]{}</tt>.
209+
* Header keys must not contain uppercase ASCII characters (A-Z).
210+
* Header values must be either a +String+, or an +Array+ of +String+ values, such that each +String+ must not contain characters with an ASCII ordinal below 040 (32).
211211

212212
==== The <tt>content-type</tt> Header
213213

@@ -221,7 +221,7 @@ There must not be a <tt>content-length</tt> header key when the status is <tt>1x
221221

222222
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.
223223

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.
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.
225225

226226
=== The Body
227227

@@ -239,17 +239,17 @@ If the Body responds to +to_path+, it must return either +nil+ or a +String+. If
239239

240240
==== Enumerable Body
241241

242-
The Enumerable Body must respond to +each+, which must not be called more than once, and must not be called after being closed. The +each+ method must only yield +String+ values.
242+
The Enumerable Body must respond to +each+, which must only be called once, must not be called after being closed, and must only yield +String+ values.
243243

244244
Middleware must not call +each+ directly on the Body. Instead, middleware can return a new Body that calls +each+ on the original Body, yielding at least once per iteration.
245245

246246
If the Body responds to +to_ary+, it must return an +Array+ whose contents are identical to that produced by calling +each+. Middleware may call +to_ary+ directly on the Body and return a new Body in its place. In other words, middleware can only process the Body directly if it responds to +to_ary+. If the Body responds to both +to_ary+ and +close+, its implementation of +to_ary+ must call +close+.
247247

248248
==== Streaming Body
249249

250-
The Streaming Body must respond to +call+, which must not be called more than once, and must not be called after being closed. The +call+ method must accept a +stream+ argument.
250+
The Streaming Body must respond to +call+, which must only be called once, must not be called after being closed, and accept a +stream+ argument.
251251

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.
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.
253253

254254
== Thanks
255255

lib/rack/lint.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def check_environment(env)
213213
raise LintError, "Only OPTIONS requests may have PATH_INFO set to '*' (asterisk-form)"
214214
end
215215
when REQUEST_PATH_AUTHORITY_FORM
216-
## * 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.
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.
217217
unless env[REQUEST_METHOD] == CONNECT
218218
raise LintError, "Only CONNECT requests may have PATH_INFO set to an authority (authority-form)"
219219
end
@@ -325,7 +325,7 @@ def check_environment(env)
325325
##
326326
## ==== <tt>rack.protocol</tt>
327327
##
328-
## 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>).
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+).
329329
if protocols = env[RACK_PROTOCOL]
330330
unless protocols.is_a?(Array) && protocols.all?{|protocol| protocol.is_a?(String)}
331331
raise LintError, "rack.protocol must be an Array of Strings"
@@ -610,11 +610,11 @@ def close(*args)
610610
##
611611
## 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.
612612
##
613-
## 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.
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.
614614
##
615615
## ==== Full Hijack
616616
##
617-
## 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.
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.
618618
##
619619
def check_hijack(env)
620620
## If <tt>rack.hijack</tt> is present in +env+, it must respond to +call+ \
@@ -624,7 +624,7 @@ def check_hijack(env)
624624
env[RACK_HIJACK] = proc do
625625
io = original_hijack.call
626626

627-
## and return an +IO+ object which can be used to read and write to the underlying connection using <tt>HTTP/1</tt> semantics and formatting.
627+
## and return an +IO+ object which can be used to read and write to the underlying connection using HTTP/1 semantics and formatting.
628628
raise LintError, "rack.hijack must return an IO instance" unless io.is_a?(IO)
629629

630630
io
@@ -724,9 +724,9 @@ def check_headers(headers)
724724
##
725725
## * The headers must not contain a <tt>"status"</tt> key.
726726
raise LintError, "headers must not contain status" if key == "status"
727-
## * Header keys must conform to {RFC7230}[https://tools.ietf.org/html/rfc7230] token specification, i.e. cannot contain non-printable <tt>ASCII</tt>, <tt>DQUOTE</tt> or <tt>(),/:;<=>?@[\]{}</tt>.
727+
## * Header keys must conform to {RFC7230}[https://tools.ietf.org/html/rfc7230] token specification, i.e. cannot contain non-printable ASCII, <tt>DQUOTE</tt> or <tt>(),/:;<=>?@[\]{}</tt>.
728728
raise LintError, "invalid header name: #{key}" if key =~ /[\(\),\/:;<=>\?@\[\\\]{}[:cntrl:]]/
729-
## * Header keys must not contain uppercase <tt>ASCII</tt> characters (A-Z).
729+
## * Header keys must not contain uppercase ASCII characters (A-Z).
730730
raise LintError, "uppercase character in header name: #{key}" if key =~ /[A-Z]/
731731

732732
## * Header values must be either a +String+, \
@@ -742,7 +742,7 @@ def check_headers(headers)
742742
end
743743

744744
def check_header_value(key, value)
745-
## such that each +String+ must not contain characters with an <tt>ASCII</tt> ordinal below <tt>040</tt> (32).
745+
## such that each +String+ must not contain characters with an ASCII ordinal below 040 (32).
746746
if value =~ /[\000-\037]/
747747
raise LintError, "invalid header value #{key}: #{value.inspect}"
748748
end
@@ -808,7 +808,7 @@ def check_rack_protocol_header(status, headers)
808808
end
809809
end
810810
##
811-
## 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.
811+
## 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.
812812
##
813813
## === The Body
814814
##
@@ -851,13 +851,13 @@ def verify_to_path
851851
## ==== Enumerable Body
852852
##
853853
def each
854-
## The Enumerable Body must respond to +each+. \
854+
## The Enumerable Body must respond to +each+, \
855855
raise LintError, "Enumerable Body must respond to each" unless @body.respond_to?(:each)
856856

857-
## It must only be consumed once (calling this method consumes the body). \
857+
## which must only be called once, \
858858
raise LintError, "Response body must only be consumed once (#{@consumed})" unless @consumed.nil?
859859

860-
## It must not be called after being closed, \
860+
## must not be called after being closed, \
861861
raise LintError, "Response body is already closed" if @closed
862862

863863
@consumed = :each
@@ -917,18 +917,18 @@ def to_ary
917917
## ==== Streaming Body
918918
##
919919
def call(stream)
920-
## The Streaming Body must respond to +call+. \
920+
## The Streaming Body must respond to +call+, \
921921
raise LintError, "Streaming Body must respond to call" unless @body.respond_to?(:call)
922922

923-
## It must only be consumed once (calling this method consumes the body). \
923+
## which must only be called once, \
924924
raise LintError, "Response body must only be consumed once (#{@consumed})" unless @consumed.nil?
925925

926-
## It must not be called after being closed. \
926+
## must not be called after being closed, \
927927
raise LintError, "Response body is already closed" if @closed
928928

929929
@consumed = :call
930930

931-
## It takes a +stream+ argument.
931+
## and accept a +stream+ argument.
932932
##
933933
## The +stream+ argument must respond to: +read+, +write+, <tt><<</tt>, +flush+, +close+, +close_read+, +close_write+, and +closed?+. \
934934
@body.call(StreamWrapper.new(stream))
@@ -937,7 +937,7 @@ def call(stream)
937937
class StreamWrapper
938938
extend Forwardable
939939

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 <tt>HTTP/2+</tt>), the server may need to provide a wrapper that implements the required methods, in order to provide the correct semantics.
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.
941941
REQUIRED_METHODS = [
942942
:read, :write, :<<, :flush, :close,
943943
:close_read, :close_write, :closed?

0 commit comments

Comments
 (0)