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
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ A Rack application is a Ruby object that responds to +call+. It takes exactly on
8
8
9
9
== The Request Environment
10
10
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.
12
12
13
13
=== CGI Variables
14
14
@@ -145,13 +145,13 @@ If present, an array of callables that will be run by the server after the respo
145
145
=== The Input Stream
146
146
147
147
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>.
149
149
* +read+ behaves like <tt>IO#read</tt>. Its signature is <tt>read([length, [buffer]])</tt>.
150
150
* If given, +length+ must be a non-negative Integer (>= 0) or +nil+, and +buffer+ must be a +String+ and may not be +nil+.
151
151
* If +length+ is given and not +nil+, then this method reads at most +length+ bytes from the input stream.
152
152
* If +length+ is not given or +nil+, then this method reads all data until <tt>EOF</tt>.
153
153
* 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+.
155
155
* +each+ must be called without arguments and only yield +String+ values.
156
156
* +close+ can be called on the input stream to indicate that any remaining input is not needed.
157
157
@@ -173,15 +173,15 @@ Full hijacking only works with <tt>HTTP/1</tt>. Partial hijacking is functionall
173
173
174
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 <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.
177
177
178
178
==== Partial Hijack
179
179
180
180
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.
181
181
182
182
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.
183
183
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.
185
185
186
186
The special response header <tt>rack.hijack</tt> must only be set if the request +env+ has a truthy <tt>rack.hijack?</tt>.
187
187
@@ -202,12 +202,12 @@ This is an HTTP status. It must be an Integer greater than or equal to 100.
202
202
203
203
=== The Headers
204
204
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.
206
206
207
207
* The headers must not contain a <tt>"status"</tt> key.
208
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
209
* 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).
211
211
212
212
==== The <tt>content-type</tt> Header
213
213
@@ -225,7 +225,7 @@ Setting this value informs the server that it should perform a connection upgrad
225
225
226
226
=== The Body
227
227
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.
229
229
230
230
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.
Copy file name to clipboardExpand all lines: lib/rack/lint.rb
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -138,7 +138,7 @@ def response
138
138
##
139
139
## Incoming HTTP requests are represented using an environment. \
140
140
defcheck_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. \
142
142
raiseLintError,"env #{env.inspect} is not a Hash, but #{env.class}"unlessenv.kind_of?Hash
143
143
raiseLintError,"env should not be frozen, but is"ifenv.frozen?
144
144
@@ -502,7 +502,7 @@ def initialize(input)
502
502
@input=input
503
503
end
504
504
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>.
506
506
defgets(*args)
507
507
raiseLintError,"rack.input#gets called with arguments"unlessargs.size == 0
508
508
@@ -520,7 +520,7 @@ def gets(*args)
520
520
## * If +length+ is given and not +nil+, then this method reads at most +length+ bytes from the input stream.
521
521
## * If +length+ is not given or +nil+, then this method reads all data until <tt>EOF</tt>.
522
522
## * 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+.
524
524
defread(*args)
525
525
unlessargs.size <= 2
526
526
raiseLintError,"rack.input#read called with too many arguments"
@@ -628,7 +628,7 @@ def check_hijack(env)
628
628
env[RACK_HIJACK]=procdo
629
629
io=original_hijack.call
630
630
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.
632
632
raiseLintError,"rack.hijack must return an IO instance"unlessio.is_a?(IO)
## 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.
660
660
else
661
661
##
662
662
## 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)
707
707
## === The Headers
708
708
##
709
709
defcheck_headers(headers)
710
-
## The headers must be a unfrozen +Hash+. \
710
+
## The headers must be an unfrozen +Hash+. \
711
711
unlessheaders.kind_of?(Hash)
712
712
raiseLintError,"headers object should be a hash, but isn't (got #{headers.class} as headers)"
713
713
end
@@ -717,7 +717,7 @@ def check_headers(headers)
717
717
end
718
718
719
719
headers.eachdo |key,value|
720
-
## The header keys must be +String+ objects. \
720
+
## The header keys must be +String+ values. \
721
721
unlesskey.kind_of?String
722
722
raiseLintError,"header key must be a string, was #{key.class}"
723
723
end
@@ -733,7 +733,7 @@ def check_headers(headers)
733
733
## * Header keys must not contain uppercase <tt>ASCII</tt> characters (A-Z).
734
734
raiseLintError,"uppercase character in header name: #{key}"ifkey =~ /[A-Z]/
735
735
736
-
## * Header values must be either a +String+ value, \
736
+
## * Header values must be either a +String+, \
737
737
ifvalue.kind_of?(String)
738
738
check_header_value(key,value)
739
739
elsifvalue.kind_of?(Array)
@@ -746,7 +746,7 @@ def check_headers(headers)
746
746
end
747
747
748
748
defcheck_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).
750
750
ifvalue =~ /[\000-\037]/
751
751
raiseLintError,"invalid header value #{key}: #{value.inspect}"
## 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.
820
820
##
821
821
## 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.
0 commit comments