Skip to content

Commit 2baae19

Browse files
Consistent usage of instance/object/value. Fixes rack#2304.
1 parent aa5698f commit 2baae19

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

SPEC.rdoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A Rack application is a Ruby object that responds to +call+. It takes exactly on
88

99
== The Request Environment
1010

11-
Incoming HTTP requests are represented using an environment. The environment must be an unfrozen instance of +Hash+. The Rack application is free to modify the environment, but the modified environment should also comply with this specification. All environment keys must be strings.
11+
Incoming HTTP requests are represented using an environment. The environment must be an unfrozen +Hash+. The Rack application is free to modify the environment, but the modified environment should also comply with this specification. All environment keys must be strings.
1212

1313
=== CGI Variables
1414

@@ -145,13 +145,13 @@ If present, an array of callables that will be run by the server after the respo
145145
=== The Input Stream
146146

147147
The input stream is an +IO+-like object which contains the raw HTTP request data. When applicable, its external encoding must be <tt>ASCII-8BIT</tt> and it must be opened in binary mode. The input stream must respond to +gets+, +each+, and +read+:
148-
* +gets+ must be called without arguments and return a string, or +nil+ on <tt>EOF</tt>.
148+
* +gets+ must be called without arguments and return a +String+, or +nil+ on <tt>EOF</tt>.
149149
* +read+ behaves like <tt>IO#read</tt>. Its signature is <tt>read([length, [buffer]])</tt>.
150150
* If given, +length+ must be a non-negative Integer (>= 0) or +nil+, and +buffer+ must be a +String+ and may not be +nil+.
151151
* If +length+ is given and not +nil+, then this method reads at most +length+ bytes from the input stream.
152152
* If +length+ is not given or +nil+, then this method reads all data until <tt>EOF</tt>.
153153
* When <tt>EOF</tt> is reached, this method returns +nil+ if +length+ is given and not +nil+, or +""+ if +length+ is not given or is +nil+.
154-
* If +buffer+ is given, then the read data will be placed into +buffer+ instead of a newly created +String+ object.
154+
* If +buffer+ is given, then the read data will be placed into +buffer+ instead of a newly created +String+.
155155
* +each+ must be called without arguments and only yield +String+ values.
156156
* +close+ can be called on the input stream to indicate that any remaining input is not needed.
157157

@@ -173,15 +173,15 @@ Full hijacking only works with <tt>HTTP/1</tt>. Partial hijacking is functionall
173173

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

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

178178
==== Partial Hijack
179179

180180
Partial hijack is used for bi-directional streaming of the request and response body. It occurs after the status and headers are written by the server and causes the server to ignore the Body of the response. It is intended to be used when applications need bi-directional streaming.
181181

182182
If <tt>rack.hijack?</tt> is present in +env+ and truthy, an application may set the special response header <tt>rack.hijack</tt> to an object that responds to +call+, accepting a +stream+ argument.
183183

184-
After the response status and headers have been sent, this hijack callback will be invoked with a +stream+ argument which follows the same interface as outlined in "Streaming Body". Servers must ignore the +body+ part of the response tuple when the <tt>rack.hijack</tt> response header is present. Using an empty +Array+ instance is recommended.
184+
After the response status and headers have been sent, this hijack callback will be invoked with a +stream+ argument which follows the same interface as outlined in "Streaming Body". Servers must ignore the +body+ part of the response tuple when the <tt>rack.hijack</tt> response header is present. Using an empty +Array+ is recommended.
185185

186186
The special response header <tt>rack.hijack</tt> must only be set if the request +env+ has a truthy <tt>rack.hijack?</tt>.
187187

@@ -202,12 +202,12 @@ This is an HTTP status. It must be an Integer greater than or equal to 100.
202202

203203
=== The Headers
204204

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.
205+
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.
208208
* 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>.
209209
* Header keys must not contain uppercase <tt>ASCII</tt> characters (A-Z).
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 <tt>ASCII</tt> ordinal below <tt>040</tt> (32).
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).
211211

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

@@ -225,7 +225,7 @@ Setting this value informs the server that it should perform a connection upgrad
225225

226226
=== The Body
227227

228-
The Body is typically an +Array+ of +String+ values, an enumerable that yields +String+ values, a +Proc+ instance, or a File-like object.
228+
The Body is typically an +Array+ of +String+ values, an enumerable that yields +String+ values, a +Proc+, or a +File+-like object.
229229

230230
The Body must respond to +each+ or +call+. It may optionally respond to +to_path+ or +to_ary+. A Body that responds to +each+ is considered to be an Enumerable Body. A Body that responds to +call+ is considered to be a Streaming Body.
231231

lib/rack/lint.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def response
138138
##
139139
## Incoming HTTP requests are represented using an environment. \
140140
def check_environment(env)
141-
## The environment must be an unfrozen instance of +Hash+. The Rack application is free to modify the environment, but the modified environment should also comply with this specification. \
141+
## The environment must be an unfrozen +Hash+. The Rack application is free to modify the environment, but the modified environment should also comply with this specification. \
142142
raise LintError, "env #{env.inspect} is not a Hash, but #{env.class}" unless env.kind_of? Hash
143143
raise LintError, "env should not be frozen, but is" if env.frozen?
144144

@@ -502,7 +502,7 @@ def initialize(input)
502502
@input = input
503503
end
504504

505-
## * +gets+ must be called without arguments and return a string, or +nil+ on <tt>EOF</tt>.
505+
## * +gets+ must be called without arguments and return a +String+, or +nil+ on <tt>EOF</tt>.
506506
def gets(*args)
507507
raise LintError, "rack.input#gets called with arguments" unless args.size == 0
508508

@@ -520,7 +520,7 @@ def gets(*args)
520520
## * If +length+ is given and not +nil+, then this method reads at most +length+ bytes from the input stream.
521521
## * If +length+ is not given or +nil+, then this method reads all data until <tt>EOF</tt>.
522522
## * When <tt>EOF</tt> is reached, this method returns +nil+ if +length+ is given and not +nil+, or +""+ if +length+ is not given or is +nil+.
523-
## * If +buffer+ is given, then the read data will be placed into +buffer+ instead of a newly created +String+ object.
523+
## * If +buffer+ is given, then the read data will be placed into +buffer+ instead of a newly created +String+.
524524
def read(*args)
525525
unless args.size <= 2
526526
raise LintError, "rack.input#read called with too many arguments"
@@ -628,7 +628,7 @@ def check_hijack(env)
628628
env[RACK_HIJACK] = proc do
629629
io = original_hijack.call
630630

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.
631+
## 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.
632632
raise LintError, "rack.hijack must return an IO instance" unless io.is_a?(IO)
633633

634634
io
@@ -656,7 +656,7 @@ def check_hijack_response(headers, env)
656656
end
657657
end
658658
##
659-
## After the response status and headers have been sent, this hijack callback will be invoked with a +stream+ argument which follows the same interface as outlined in "Streaming Body". Servers must ignore the +body+ part of the response tuple when the <tt>rack.hijack</tt> response header is present. Using an empty +Array+ instance is recommended.
659+
## After the response status and headers have been sent, this hijack callback will be invoked with a +stream+ argument which follows the same interface as outlined in "Streaming Body". Servers must ignore the +body+ part of the response tuple when the <tt>rack.hijack</tt> response header is present. Using an empty +Array+ is recommended.
660660
else
661661
##
662662
## The special response header <tt>rack.hijack</tt> must only be set if the request +env+ has a truthy <tt>rack.hijack?</tt>.
@@ -707,7 +707,7 @@ def check_status(status)
707707
## === The Headers
708708
##
709709
def check_headers(headers)
710-
## The headers must be a unfrozen +Hash+. \
710+
## The headers must be an unfrozen +Hash+. \
711711
unless headers.kind_of?(Hash)
712712
raise LintError, "headers object should be a hash, but isn't (got #{headers.class} as headers)"
713713
end
@@ -717,7 +717,7 @@ def check_headers(headers)
717717
end
718718

719719
headers.each do |key, value|
720-
## The header keys must be +String+ objects. \
720+
## The header keys must be +String+ values. \
721721
unless key.kind_of? String
722722
raise LintError, "header key must be a string, was #{key.class}"
723723
end
@@ -733,7 +733,7 @@ def check_headers(headers)
733733
## * Header keys must not contain uppercase <tt>ASCII</tt> characters (A-Z).
734734
raise LintError, "uppercase character in header name: #{key}" if key =~ /[A-Z]/
735735

736-
## * Header values must be either a +String+ value, \
736+
## * Header values must be either a +String+, \
737737
if value.kind_of?(String)
738738
check_header_value(key, value)
739739
elsif value.kind_of?(Array)
@@ -746,7 +746,7 @@ def check_headers(headers)
746746
end
747747

748748
def check_header_value(key, value)
749-
## such that each +String+ value must not contain characters with an <tt>ASCII</tt> ordinal below <tt>040</tt> (32).
749+
## such that each +String+ must not contain characters with an <tt>ASCII</tt> ordinal below <tt>040</tt> (32).
750750
if value =~ /[\000-\037]/
751751
raise LintError, "invalid header value #{key}: #{value.inspect}"
752752
end
@@ -816,7 +816,7 @@ def check_rack_protocol_header(status, headers)
816816
##
817817
## === The Body
818818
##
819-
## The Body is typically an +Array+ of +String+ values, an enumerable that yields +String+ values, a +Proc+ instance, or a File-like object.
819+
## The Body is typically an +Array+ of +String+ values, an enumerable that yields +String+ values, a +Proc+, or a +File+-like object.
820820
##
821821
## The Body must respond to +each+ or +call+. It may optionally respond to +to_path+ or +to_ary+. A Body that responds to +each+ is considered to be an Enumerable Body. A Body that responds to +call+ is considered to be a Streaming Body.
822822
##

0 commit comments

Comments
 (0)