rack 2.0.8 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rack might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +690 -0
- data/CONTRIBUTING.md +136 -0
- data/{COPYING → MIT-LICENSE} +4 -2
- data/README.rdoc +152 -148
- data/Rakefile +37 -23
- data/{SPEC → SPEC.rdoc} +29 -5
- data/bin/rackup +1 -0
- data/example/lobster.ru +2 -0
- data/example/protectedlobster.rb +3 -1
- data/example/protectedlobster.ru +2 -0
- data/lib/rack.rb +67 -73
- data/lib/rack/auth/abstract/handler.rb +3 -1
- data/lib/rack/auth/abstract/request.rb +1 -1
- data/lib/rack/auth/basic.rb +7 -4
- data/lib/rack/auth/digest/md5.rb +13 -11
- data/lib/rack/auth/digest/nonce.rb +6 -3
- data/lib/rack/auth/digest/params.rb +4 -2
- data/lib/rack/auth/digest/request.rb +5 -3
- data/lib/rack/body_proxy.rb +15 -14
- data/lib/rack/builder.rb +116 -23
- data/lib/rack/cascade.rb +28 -12
- data/lib/rack/chunked.rb +68 -20
- data/lib/rack/common_logger.rb +33 -25
- data/lib/rack/conditional_get.rb +20 -16
- data/lib/rack/config.rb +2 -0
- data/lib/rack/content_length.rb +8 -7
- data/lib/rack/content_type.rb +5 -4
- data/lib/rack/core_ext/regexp.rb +14 -0
- data/lib/rack/deflater.rb +59 -34
- data/lib/rack/directory.rb +84 -64
- data/lib/rack/etag.rb +5 -4
- data/lib/rack/events.rb +19 -20
- data/lib/rack/file.rb +4 -173
- data/lib/rack/files.rb +218 -0
- data/lib/rack/handler.rb +7 -2
- data/lib/rack/handler/cgi.rb +2 -3
- data/lib/rack/handler/fastcgi.rb +4 -4
- data/lib/rack/handler/lsws.rb +3 -3
- data/lib/rack/handler/scgi.rb +9 -8
- data/lib/rack/handler/thin.rb +3 -3
- data/lib/rack/handler/webrick.rb +15 -6
- data/lib/rack/head.rb +1 -1
- data/lib/rack/lint.rb +71 -25
- data/lib/rack/lobster.rb +10 -10
- data/lib/rack/lock.rb +2 -1
- data/lib/rack/logger.rb +2 -0
- data/lib/rack/media_type.rb +10 -5
- data/lib/rack/method_override.rb +4 -2
- data/lib/rack/mime.rb +9 -1
- data/lib/rack/mock.rb +97 -20
- data/lib/rack/multipart.rb +6 -4
- data/lib/rack/multipart/generator.rb +17 -13
- data/lib/rack/multipart/parser.rb +54 -56
- data/lib/rack/multipart/uploaded_file.rb +15 -7
- data/lib/rack/null_logger.rb +2 -0
- data/lib/rack/query_parser.rb +53 -28
- data/lib/rack/recursive.rb +7 -5
- data/lib/rack/reloader.rb +8 -4
- data/lib/rack/request.rb +220 -61
- data/lib/rack/response.rb +127 -44
- data/lib/rack/rewindable_input.rb +4 -3
- data/lib/rack/runtime.rb +6 -4
- data/lib/rack/sendfile.rb +13 -9
- data/lib/rack/server.rb +95 -24
- data/lib/rack/session/abstract/id.rb +36 -23
- data/lib/rack/session/cookie.rb +11 -12
- data/lib/rack/session/memcache.rb +4 -93
- data/lib/rack/session/pool.rb +5 -3
- data/lib/rack/show_exceptions.rb +21 -17
- data/lib/rack/show_status.rb +9 -9
- data/lib/rack/static.rb +23 -11
- data/lib/rack/tempfile_reaper.rb +1 -1
- data/lib/rack/urlmap.rb +12 -6
- data/lib/rack/utils.rb +98 -109
- data/lib/rack/version.rb +29 -0
- data/rack.gemspec +40 -28
- metadata +36 -177
- data/HISTORY.md +0 -505
- data/test/builder/an_underscore_app.rb +0 -5
- data/test/builder/anything.rb +0 -5
- data/test/builder/comment.ru +0 -4
- data/test/builder/end.ru +0 -5
- data/test/builder/line.ru +0 -1
- data/test/builder/options.ru +0 -2
- data/test/cgi/assets/folder/test.js +0 -1
- data/test/cgi/assets/fonts/font.eot +0 -1
- data/test/cgi/assets/images/image.png +0 -1
- data/test/cgi/assets/index.html +0 -1
- data/test/cgi/assets/javascripts/app.js +0 -1
- data/test/cgi/assets/stylesheets/app.css +0 -1
- data/test/cgi/lighttpd.conf +0 -26
- data/test/cgi/rackup_stub.rb +0 -6
- data/test/cgi/sample_rackup.ru +0 -5
- data/test/cgi/test +0 -9
- data/test/cgi/test+directory/test+file +0 -1
- data/test/cgi/test.fcgi +0 -9
- data/test/cgi/test.gz +0 -0
- data/test/cgi/test.ru +0 -5
- data/test/gemloader.rb +0 -10
- data/test/helper.rb +0 -34
- data/test/multipart/bad_robots +0 -259
- data/test/multipart/binary +0 -0
- data/test/multipart/content_type_and_no_filename +0 -6
- data/test/multipart/empty +0 -10
- data/test/multipart/fail_16384_nofile +0 -814
- data/test/multipart/file1.txt +0 -1
- data/test/multipart/filename_and_modification_param +0 -7
- data/test/multipart/filename_and_no_name +0 -6
- data/test/multipart/filename_with_encoded_words +0 -7
- data/test/multipart/filename_with_escaped_quotes +0 -6
- data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
- data/test/multipart/filename_with_null_byte +0 -7
- data/test/multipart/filename_with_percent_escaped_quotes +0 -6
- data/test/multipart/filename_with_single_quote +0 -7
- data/test/multipart/filename_with_unescaped_percentages +0 -6
- data/test/multipart/filename_with_unescaped_percentages2 +0 -6
- data/test/multipart/filename_with_unescaped_percentages3 +0 -6
- data/test/multipart/filename_with_unescaped_quotes +0 -6
- data/test/multipart/ie +0 -6
- data/test/multipart/invalid_character +0 -6
- data/test/multipart/mixed_files +0 -21
- data/test/multipart/nested +0 -10
- data/test/multipart/none +0 -9
- data/test/multipart/quoted +0 -15
- data/test/multipart/rack-logo.png +0 -0
- data/test/multipart/semicolon +0 -6
- data/test/multipart/text +0 -15
- data/test/multipart/three_files_three_fields +0 -31
- data/test/multipart/unity3d_wwwform +0 -11
- data/test/multipart/webkit +0 -32
- data/test/rackup/config.ru +0 -31
- data/test/registering_handler/rack/handler/registering_myself.rb +0 -8
- data/test/spec_auth_basic.rb +0 -89
- data/test/spec_auth_digest.rb +0 -260
- data/test/spec_body_proxy.rb +0 -85
- data/test/spec_builder.rb +0 -233
- data/test/spec_cascade.rb +0 -63
- data/test/spec_cgi.rb +0 -84
- data/test/spec_chunked.rb +0 -103
- data/test/spec_common_logger.rb +0 -95
- data/test/spec_conditional_get.rb +0 -103
- data/test/spec_config.rb +0 -23
- data/test/spec_content_length.rb +0 -86
- data/test/spec_content_type.rb +0 -46
- data/test/spec_deflater.rb +0 -375
- data/test/spec_directory.rb +0 -148
- data/test/spec_etag.rb +0 -108
- data/test/spec_events.rb +0 -133
- data/test/spec_fastcgi.rb +0 -85
- data/test/spec_file.rb +0 -264
- data/test/spec_handler.rb +0 -57
- data/test/spec_head.rb +0 -46
- data/test/spec_lint.rb +0 -515
- data/test/spec_lobster.rb +0 -59
- data/test/spec_lock.rb +0 -204
- data/test/spec_logger.rb +0 -24
- data/test/spec_media_type.rb +0 -42
- data/test/spec_method_override.rb +0 -110
- data/test/spec_mime.rb +0 -51
- data/test/spec_mock.rb +0 -359
- data/test/spec_multipart.rb +0 -722
- data/test/spec_null_logger.rb +0 -21
- data/test/spec_recursive.rb +0 -75
- data/test/spec_request.rb +0 -1407
- data/test/spec_response.rb +0 -510
- data/test/spec_rewindable_input.rb +0 -128
- data/test/spec_runtime.rb +0 -50
- data/test/spec_sendfile.rb +0 -125
- data/test/spec_server.rb +0 -193
- data/test/spec_session_abstract_id.rb +0 -31
- data/test/spec_session_abstract_session_hash.rb +0 -45
- data/test/spec_session_cookie.rb +0 -442
- data/test/spec_session_memcache.rb +0 -357
- data/test/spec_session_pool.rb +0 -247
- data/test/spec_show_exceptions.rb +0 -93
- data/test/spec_show_status.rb +0 -104
- data/test/spec_static.rb +0 -184
- data/test/spec_tempfile_reaper.rb +0 -64
- data/test/spec_thin.rb +0 -96
- data/test/spec_urlmap.rb +0 -237
- data/test/spec_utils.rb +0 -742
- data/test/spec_version.rb +0 -11
- data/test/spec_webrick.rb +0 -206
- data/test/static/another/index.html +0 -1
- data/test/static/foo.html +0 -1
- data/test/static/index.html +0 -1
- data/test/testrequest.rb +0 -78
- data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
- data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +0 -7
data/Rakefile
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
2
5
|
|
3
6
|
desc "Run all the tests"
|
4
|
-
task :
|
7
|
+
task default: :test
|
5
8
|
|
6
9
|
desc "Install gem dependencies"
|
7
10
|
task :deps do
|
@@ -16,9 +19,9 @@ task :deps do
|
|
16
19
|
end
|
17
20
|
|
18
21
|
desc "Make an archive as .tar.gz"
|
19
|
-
task :
|
22
|
+
task dist: %w[chmod changelog spec rdoc] do
|
20
23
|
sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
|
21
|
-
sh "pax -waf #{release}.tar -s ':^:#{release}/:' SPEC ChangeLog doc rack.gemspec"
|
24
|
+
sh "pax -waf #{release}.tar -s ':^:#{release}/:' SPEC.rdoc ChangeLog doc rack.gemspec"
|
22
25
|
sh "gzip -f -9 #{release}.tar"
|
23
26
|
end
|
24
27
|
|
@@ -31,12 +34,12 @@ task :officialrelease do
|
|
31
34
|
sh "mv stage/#{release}.tar.gz stage/#{release}.gem ."
|
32
35
|
end
|
33
36
|
|
34
|
-
task :
|
37
|
+
task officialrelease_really: %w[spec dist gem] do
|
35
38
|
sh "shasum #{release}.tar.gz #{release}.gem"
|
36
39
|
end
|
37
40
|
|
38
41
|
def release
|
39
|
-
"rack-" + File.read('lib/rack.rb')[/RELEASE += +([\"\'])([\d][\w\.]+)\1/, 2]
|
42
|
+
"rack-" + File.read('lib/rack/version.rb')[/RELEASE += +([\"\'])([\d][\w\.]+)\1/, 2]
|
40
43
|
end
|
41
44
|
|
42
45
|
desc "Make binaries executable"
|
@@ -46,7 +49,7 @@ task :chmod do
|
|
46
49
|
end
|
47
50
|
|
48
51
|
desc "Generate a ChangeLog"
|
49
|
-
task :
|
52
|
+
task changelog: "ChangeLog"
|
50
53
|
|
51
54
|
file '.git/index'
|
52
55
|
file "ChangeLog" => '.git/index' do
|
@@ -68,48 +71,59 @@ file "ChangeLog" => '.git/index' do
|
|
68
71
|
}
|
69
72
|
end
|
70
73
|
|
71
|
-
file 'lib/rack/lint.rb'
|
72
74
|
desc "Generate Rack Specification"
|
73
|
-
|
74
|
-
|
75
|
+
task spec: "SPEC.rdoc"
|
76
|
+
|
77
|
+
file 'lib/rack/lint.rb'
|
78
|
+
file "SPEC.rdoc" => 'lib/rack/lint.rb' do
|
79
|
+
File.open("SPEC.rdoc", "wb") { |file|
|
75
80
|
IO.foreach("lib/rack/lint.rb") { |line|
|
76
|
-
if line =~
|
81
|
+
if line =~ /^\s*## ?(.*)/
|
77
82
|
file.puts $1
|
78
83
|
end
|
79
84
|
}
|
80
85
|
}
|
81
86
|
end
|
82
87
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
88
|
+
Rake::TestTask.new("test:regular") do |t|
|
89
|
+
t.libs << "test"
|
90
|
+
t.test_files = FileList["test/**/*_test.rb", "test/**/spec_*.rb", "test/gemloader.rb"]
|
91
|
+
t.warning = false
|
92
|
+
t.verbose = true
|
93
|
+
end
|
87
94
|
|
88
|
-
|
95
|
+
desc "Run tests with coverage"
|
96
|
+
task "test_cov" do
|
97
|
+
ENV['COVERAGE'] = '1'
|
98
|
+
Rake::Task['test:regular'].invoke
|
89
99
|
end
|
90
100
|
|
101
|
+
desc "Run all the fast + platform agnostic tests"
|
102
|
+
task test: %w[spec test:regular]
|
103
|
+
|
91
104
|
desc "Run all the tests we run on CI"
|
92
|
-
task :
|
105
|
+
task ci: :test
|
93
106
|
|
94
|
-
task :
|
107
|
+
task gem: :spec do
|
95
108
|
sh "gem build rack.gemspec"
|
96
109
|
end
|
97
110
|
|
98
|
-
task :
|
111
|
+
task doc: :rdoc
|
112
|
+
|
99
113
|
desc "Generate RDoc documentation"
|
100
|
-
task :
|
114
|
+
task rdoc: %w[changelog spec] do
|
101
115
|
sh(*%w{rdoc --line-numbers --main README.rdoc
|
102
116
|
--title 'Rack\ Documentation' --charset utf-8 -U -o doc} +
|
103
|
-
%w{README.rdoc KNOWN-ISSUES SPEC ChangeLog} +
|
117
|
+
%w{README.rdoc KNOWN-ISSUES SPEC.rdoc ChangeLog} +
|
104
118
|
`git ls-files lib/\*\*/\*.rb`.strip.split)
|
105
119
|
cp "contrib/rdoc.css", "doc/rdoc.css"
|
106
120
|
end
|
107
121
|
|
108
|
-
task :
|
122
|
+
task pushdoc: :rdoc do
|
109
123
|
sh "rsync -avz doc/ rack.rubyforge.org:/var/www/gforge-projects/rack/doc/"
|
110
124
|
end
|
111
125
|
|
112
|
-
task :
|
126
|
+
task pushsite: :pushdoc do
|
113
127
|
sh "cd site && git gc"
|
114
128
|
sh "rsync -avz site/ rack.rubyforge.org:/var/www/gforge-projects/rack/"
|
115
129
|
sh "cd site && git push"
|
data/{SPEC → SPEC.rdoc}
RENAMED
@@ -1,5 +1,6 @@
|
|
1
1
|
This specification aims to formalize the Rack protocol. You
|
2
2
|
can (and should) use Rack::Lint to enforce it.
|
3
|
+
|
3
4
|
When you develop middleware, be sure to add a Lint before and
|
4
5
|
after to catch all mistakes.
|
5
6
|
= Rack applications
|
@@ -11,9 +12,10 @@ The *status*,
|
|
11
12
|
the *headers*,
|
12
13
|
and the *body*.
|
13
14
|
== The Environment
|
14
|
-
The environment must be an instance of Hash that includes
|
15
|
+
The environment must be an unfrozen instance of Hash that includes
|
15
16
|
CGI-like headers. The application is free to modify the
|
16
17
|
environment.
|
18
|
+
|
17
19
|
The environment is required to include these variables
|
18
20
|
(adopted from PEP333), except when they'd be empty, but see
|
19
21
|
below.
|
@@ -60,9 +62,8 @@ below.
|
|
60
62
|
the presence or absence of the
|
61
63
|
appropriate HTTP header in the
|
62
64
|
request. See
|
63
|
-
|
64
|
-
|
65
|
-
specific behavior.
|
65
|
+
{RFC3875 section 4.1.18}[https://tools.ietf.org/html/rfc3875#section-4.1.18]
|
66
|
+
for specific behavior.
|
66
67
|
In addition to this, the Rack environment must include these
|
67
68
|
Rack-specific variables:
|
68
69
|
<tt>rack.version</tt>:: The Array representing this version of Rack
|
@@ -105,6 +106,7 @@ be implemented by the server.
|
|
105
106
|
fetch(key, default = nil) (aliased as []);
|
106
107
|
delete(key);
|
107
108
|
clear;
|
109
|
+
to_hash (returning unfrozen Hash instance);
|
108
110
|
<tt>rack.logger</tt>:: A common object interface for logging messages.
|
109
111
|
The object must implement:
|
110
112
|
info(message, &block)
|
@@ -119,10 +121,13 @@ environment, too. The keys must contain at least one dot,
|
|
119
121
|
and should be prefixed uniquely. The prefix <tt>rack.</tt>
|
120
122
|
is reserved for use with the Rack core distribution and other
|
121
123
|
accepted specifications and must not be used otherwise.
|
124
|
+
|
122
125
|
The environment must not contain the keys
|
123
126
|
<tt>HTTP_CONTENT_TYPE</tt> or <tt>HTTP_CONTENT_LENGTH</tt>
|
124
127
|
(use the versions without <tt>HTTP_</tt>).
|
125
128
|
The CGI keys (named without a period) must have String values.
|
129
|
+
If the string values for CGI keys contain non-ASCII characters,
|
130
|
+
they should use ASCII-8BIT encoding.
|
126
131
|
There are the following restrictions:
|
127
132
|
* <tt>rack.version</tt> must be an array of Integers.
|
128
133
|
* <tt>rack.url_scheme</tt> must either be +http+ or +https+.
|
@@ -138,6 +143,7 @@ There are the following restrictions:
|
|
138
143
|
<tt>SCRIPT_NAME</tt> is empty.
|
139
144
|
<tt>SCRIPT_NAME</tt> never should be <tt>/</tt>, but instead be empty.
|
140
145
|
=== The Input Stream
|
146
|
+
|
141
147
|
The input stream is an IO-like object which contains the raw HTTP
|
142
148
|
POST data.
|
143
149
|
When applicable, its external encoding must be "ASCII-8BIT" and it
|
@@ -147,14 +153,19 @@ The input stream must respond to +gets+, +each+, +read+ and +rewind+.
|
|
147
153
|
or +nil+ on EOF.
|
148
154
|
* +read+ behaves like IO#read.
|
149
155
|
Its signature is <tt>read([length, [buffer]])</tt>.
|
156
|
+
|
150
157
|
If given, +length+ must be a non-negative Integer (>= 0) or +nil+,
|
151
158
|
and +buffer+ must be a String and may not be nil.
|
159
|
+
|
152
160
|
If +length+ is given and not nil, then this method reads at most
|
153
161
|
+length+ bytes from the input stream.
|
162
|
+
|
154
163
|
If +length+ is not given or nil, then this method reads
|
155
164
|
all data until EOF.
|
165
|
+
|
156
166
|
When EOF is reached, this method returns nil if +length+ is given
|
157
167
|
and not nil, or "" if +length+ is not given or is nil.
|
168
|
+
|
158
169
|
If +buffer+ is given, then the read data will be placed
|
159
170
|
into +buffer+ instead of a newly created String object.
|
160
171
|
* +each+ must be called without arguments and only yield Strings.
|
@@ -176,16 +187,20 @@ The error stream must respond to +puts+, +write+ and +flush+.
|
|
176
187
|
If rack.hijack? is true then rack.hijack must respond to #call.
|
177
188
|
rack.hijack must return the io that will also be assigned (or is
|
178
189
|
already present, in rack.hijack_io.
|
190
|
+
|
179
191
|
rack.hijack_io must respond to:
|
180
192
|
<tt>read, write, read_nonblock, write_nonblock, flush, close,
|
181
193
|
close_read, close_write, closed?</tt>
|
194
|
+
|
182
195
|
The semantics of these IO methods must be a best effort match to
|
183
196
|
those of a normal ruby IO or Socket object, using standard
|
184
197
|
arguments and raising standard exceptions. Servers are encouraged
|
185
198
|
to simply pass on real IO objects, although it is recognized that
|
186
199
|
this approach is not directly compatible with SPDY and HTTP 2.0.
|
200
|
+
|
187
201
|
IO provided in rack.hijack_io should preference the
|
188
202
|
IO::WaitReadable and IO::WaitWritable APIs wherever supported.
|
203
|
+
|
189
204
|
There is a deliberate lack of full specification around
|
190
205
|
rack.hijack_io, as semantics will change from server to server.
|
191
206
|
Users are encouraged to utilize this API with a knowledge of their
|
@@ -193,7 +208,9 @@ server choice, and servers may extend the functionality of
|
|
193
208
|
hijack_io to provide additional features to users. The purpose of
|
194
209
|
rack.hijack is for Rack to "get out of the way", as such, Rack only
|
195
210
|
provides the minimum of specification and support.
|
211
|
+
|
196
212
|
If rack.hijack? is false, then rack.hijack should not be set.
|
213
|
+
|
197
214
|
If rack.hijack? is false, then rack.hijack_io should not be set.
|
198
215
|
==== Response (after headers)
|
199
216
|
It is also possible to hijack a response after the status and headers
|
@@ -202,6 +219,7 @@ In order to do this, an application may set the special header
|
|
202
219
|
<tt>rack.hijack</tt> to an object that responds to <tt>call</tt>
|
203
220
|
accepting an argument that conforms to the <tt>rack.hijack_io</tt>
|
204
221
|
protocol.
|
222
|
+
|
205
223
|
After the headers have been sent, and this hijack callback has been
|
206
224
|
called, the application is now responsible for the remaining lifecycle
|
207
225
|
of the IO. The application is also responsible for maintaining HTTP
|
@@ -210,8 +228,10 @@ applications will have wanted to specify the header Connection:close in
|
|
210
228
|
HTTP/1.1, and not Connection:keep-alive, as there is no protocol for
|
211
229
|
returning hijacked sockets to the web server. For that purpose, use the
|
212
230
|
body streaming API instead (progressively yielding strings via each).
|
231
|
+
|
213
232
|
Servers must ignore the <tt>body</tt> part of the response tuple when
|
214
233
|
the <tt>rack.hijack</tt> response API is in use.
|
234
|
+
|
215
235
|
The special response header <tt>rack.hijack</tt> must only be set
|
216
236
|
if the request env has <tt>rack.hijack?</tt> <tt>true</tt>.
|
217
237
|
==== Conventions
|
@@ -226,9 +246,9 @@ This is an HTTP status. When parsed as integer (+to_i+), it must be
|
|
226
246
|
greater than or equal to 100.
|
227
247
|
=== The Headers
|
228
248
|
The header must respond to +each+, and yield values of key and value.
|
249
|
+
The header keys must be Strings.
|
229
250
|
Special headers starting "rack." are for communicating with the
|
230
251
|
server, and must not be sent back to the client.
|
231
|
-
The header keys must be Strings.
|
232
252
|
The header must not contain a +Status+ key.
|
233
253
|
The header must conform to RFC7230 token specification, i.e. cannot
|
234
254
|
contain non-printable ASCII, DQUOTE or "(),/:;<=>?@[\]{}".
|
@@ -245,16 +265,20 @@ There must not be a Content-Length header when the
|
|
245
265
|
=== The Body
|
246
266
|
The Body must respond to +each+
|
247
267
|
and must only yield String values.
|
268
|
+
|
248
269
|
The Body itself should not be an instance of String, as this will
|
249
270
|
break in Ruby 1.9.
|
271
|
+
|
250
272
|
If the Body responds to +close+, it will be called after iteration. If
|
251
273
|
the body is replaced by a middleware after action, the original body
|
252
274
|
must be closed first, if it responds to close.
|
275
|
+
|
253
276
|
If the Body responds to +to_path+, it must return a String
|
254
277
|
identifying the location of a file whose contents are identical
|
255
278
|
to that produced by calling +each+; this may be used by the
|
256
279
|
server as an alternative, possibly more efficient way to
|
257
280
|
transport the response.
|
281
|
+
|
258
282
|
The Body commonly is an Array of Strings, the application
|
259
283
|
instance itself, or a File-like object.
|
260
284
|
== Thanks
|
data/bin/rackup
CHANGED
data/example/lobster.ru
CHANGED
data/example/protectedlobster.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rack'
|
2
4
|
require 'rack/lobster'
|
3
5
|
|
@@ -11,4 +13,4 @@ protected_lobster.realm = 'Lobster 2.0'
|
|
11
13
|
|
12
14
|
pretty_protected_lobster = Rack::ShowStatus.new(Rack::ShowExceptions.new(protected_lobster))
|
13
15
|
|
14
|
-
Rack::Server.start :
|
16
|
+
Rack::Server.start app: pretty_protected_lobster, Port: 9292
|
data/example/protectedlobster.ru
CHANGED
data/lib/rack.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2007-2019 Leah Neukirchen <http://leahneukirchen.org/infopage.html>
|
2
4
|
#
|
3
5
|
# Rack is freely distributable under the terms of an MIT-style license.
|
4
|
-
# See
|
6
|
+
# See MIT-LICENSE or https://opensource.org/licenses/MIT.
|
5
7
|
|
6
8
|
# The Rack main module, serving as a namespace for all core Rack
|
7
9
|
# modules and classes.
|
@@ -9,82 +11,70 @@
|
|
9
11
|
# All modules meant for use in your application are <tt>autoload</tt>ed here,
|
10
12
|
# so it should be enough just to <tt>require 'rack'</tt> in your code.
|
11
13
|
|
12
|
-
|
13
|
-
# The Rack protocol version number implemented.
|
14
|
-
VERSION = [1,3]
|
15
|
-
|
16
|
-
# Return the Rack protocol version as a dotted string.
|
17
|
-
def self.version
|
18
|
-
VERSION.join(".")
|
19
|
-
end
|
20
|
-
|
21
|
-
RELEASE = "2.0.8"
|
22
|
-
|
23
|
-
# Return the Rack release as a dotted string.
|
24
|
-
def self.release
|
25
|
-
RELEASE
|
26
|
-
end
|
14
|
+
require_relative 'rack/version'
|
27
15
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
16
|
+
module Rack
|
17
|
+
HTTP_HOST = 'HTTP_HOST'
|
18
|
+
HTTP_PORT = 'HTTP_PORT'
|
19
|
+
HTTP_VERSION = 'HTTP_VERSION'
|
20
|
+
HTTPS = 'HTTPS'
|
21
|
+
PATH_INFO = 'PATH_INFO'
|
22
|
+
REQUEST_METHOD = 'REQUEST_METHOD'
|
23
|
+
REQUEST_PATH = 'REQUEST_PATH'
|
24
|
+
SCRIPT_NAME = 'SCRIPT_NAME'
|
25
|
+
QUERY_STRING = 'QUERY_STRING'
|
26
|
+
SERVER_PROTOCOL = 'SERVER_PROTOCOL'
|
27
|
+
SERVER_NAME = 'SERVER_NAME'
|
28
|
+
SERVER_PORT = 'SERVER_PORT'
|
29
|
+
CACHE_CONTROL = 'Cache-Control'
|
30
|
+
EXPIRES = 'Expires'
|
31
|
+
CONTENT_LENGTH = 'Content-Length'
|
32
|
+
CONTENT_TYPE = 'Content-Type'
|
33
|
+
SET_COOKIE = 'Set-Cookie'
|
34
|
+
TRANSFER_ENCODING = 'Transfer-Encoding'
|
35
|
+
HTTP_COOKIE = 'HTTP_COOKIE'
|
36
|
+
ETAG = 'ETag'
|
47
37
|
|
48
38
|
# HTTP method verbs
|
49
|
-
GET = 'GET'
|
50
|
-
POST = 'POST'
|
51
|
-
PUT = 'PUT'
|
52
|
-
PATCH = 'PATCH'
|
53
|
-
DELETE = 'DELETE'
|
54
|
-
HEAD = 'HEAD'
|
55
|
-
OPTIONS = 'OPTIONS'
|
56
|
-
LINK = 'LINK'
|
57
|
-
UNLINK = 'UNLINK'
|
58
|
-
TRACE = 'TRACE'
|
39
|
+
GET = 'GET'
|
40
|
+
POST = 'POST'
|
41
|
+
PUT = 'PUT'
|
42
|
+
PATCH = 'PATCH'
|
43
|
+
DELETE = 'DELETE'
|
44
|
+
HEAD = 'HEAD'
|
45
|
+
OPTIONS = 'OPTIONS'
|
46
|
+
LINK = 'LINK'
|
47
|
+
UNLINK = 'UNLINK'
|
48
|
+
TRACE = 'TRACE'
|
59
49
|
|
60
50
|
# Rack environment variables
|
61
|
-
RACK_VERSION = 'rack.version'
|
62
|
-
RACK_TEMPFILES = 'rack.tempfiles'
|
63
|
-
RACK_ERRORS = 'rack.errors'
|
64
|
-
RACK_LOGGER = 'rack.logger'
|
65
|
-
RACK_INPUT = 'rack.input'
|
66
|
-
RACK_SESSION = 'rack.session'
|
67
|
-
RACK_SESSION_OPTIONS = 'rack.session.options'
|
68
|
-
RACK_SHOWSTATUS_DETAIL = 'rack.showstatus.detail'
|
69
|
-
RACK_MULTITHREAD = 'rack.multithread'
|
70
|
-
RACK_MULTIPROCESS = 'rack.multiprocess'
|
71
|
-
RACK_RUNONCE = 'rack.run_once'
|
72
|
-
RACK_URL_SCHEME = 'rack.url_scheme'
|
73
|
-
RACK_HIJACK = 'rack.hijack'
|
74
|
-
RACK_IS_HIJACK = 'rack.hijack?'
|
75
|
-
RACK_HIJACK_IO = 'rack.hijack_io'
|
76
|
-
RACK_RECURSIVE_INCLUDE = 'rack.recursive.include'
|
77
|
-
RACK_MULTIPART_BUFFER_SIZE = 'rack.multipart.buffer_size'
|
78
|
-
RACK_MULTIPART_TEMPFILE_FACTORY = 'rack.multipart.tempfile_factory'
|
79
|
-
RACK_REQUEST_FORM_INPUT = 'rack.request.form_input'
|
80
|
-
RACK_REQUEST_FORM_HASH = 'rack.request.form_hash'
|
81
|
-
RACK_REQUEST_FORM_VARS = 'rack.request.form_vars'
|
82
|
-
RACK_REQUEST_COOKIE_HASH = 'rack.request.cookie_hash'
|
83
|
-
RACK_REQUEST_COOKIE_STRING = 'rack.request.cookie_string'
|
84
|
-
RACK_REQUEST_QUERY_HASH = 'rack.request.query_hash'
|
85
|
-
RACK_REQUEST_QUERY_STRING = 'rack.request.query_string'
|
86
|
-
RACK_METHODOVERRIDE_ORIGINAL_METHOD = 'rack.methodoverride.original_method'
|
87
|
-
RACK_SESSION_UNPACKED_COOKIE_DATA = 'rack.session.unpacked_cookie_data'
|
51
|
+
RACK_VERSION = 'rack.version'
|
52
|
+
RACK_TEMPFILES = 'rack.tempfiles'
|
53
|
+
RACK_ERRORS = 'rack.errors'
|
54
|
+
RACK_LOGGER = 'rack.logger'
|
55
|
+
RACK_INPUT = 'rack.input'
|
56
|
+
RACK_SESSION = 'rack.session'
|
57
|
+
RACK_SESSION_OPTIONS = 'rack.session.options'
|
58
|
+
RACK_SHOWSTATUS_DETAIL = 'rack.showstatus.detail'
|
59
|
+
RACK_MULTITHREAD = 'rack.multithread'
|
60
|
+
RACK_MULTIPROCESS = 'rack.multiprocess'
|
61
|
+
RACK_RUNONCE = 'rack.run_once'
|
62
|
+
RACK_URL_SCHEME = 'rack.url_scheme'
|
63
|
+
RACK_HIJACK = 'rack.hijack'
|
64
|
+
RACK_IS_HIJACK = 'rack.hijack?'
|
65
|
+
RACK_HIJACK_IO = 'rack.hijack_io'
|
66
|
+
RACK_RECURSIVE_INCLUDE = 'rack.recursive.include'
|
67
|
+
RACK_MULTIPART_BUFFER_SIZE = 'rack.multipart.buffer_size'
|
68
|
+
RACK_MULTIPART_TEMPFILE_FACTORY = 'rack.multipart.tempfile_factory'
|
69
|
+
RACK_REQUEST_FORM_INPUT = 'rack.request.form_input'
|
70
|
+
RACK_REQUEST_FORM_HASH = 'rack.request.form_hash'
|
71
|
+
RACK_REQUEST_FORM_VARS = 'rack.request.form_vars'
|
72
|
+
RACK_REQUEST_COOKIE_HASH = 'rack.request.cookie_hash'
|
73
|
+
RACK_REQUEST_COOKIE_STRING = 'rack.request.cookie_string'
|
74
|
+
RACK_REQUEST_QUERY_HASH = 'rack.request.query_hash'
|
75
|
+
RACK_REQUEST_QUERY_STRING = 'rack.request.query_string'
|
76
|
+
RACK_METHODOVERRIDE_ORIGINAL_METHOD = 'rack.methodoverride.original_method'
|
77
|
+
RACK_SESSION_UNPACKED_COOKIE_DATA = 'rack.session.unpacked_cookie_data'
|
88
78
|
|
89
79
|
autoload :Builder, "rack/builder"
|
90
80
|
autoload :BodyProxy, "rack/body_proxy"
|
@@ -96,7 +86,9 @@ module Rack
|
|
96
86
|
autoload :ContentLength, "rack/content_length"
|
97
87
|
autoload :ContentType, "rack/content_type"
|
98
88
|
autoload :ETag, "rack/etag"
|
89
|
+
autoload :Events, "rack/events"
|
99
90
|
autoload :File, "rack/file"
|
91
|
+
autoload :Files, "rack/files"
|
100
92
|
autoload :Deflater, "rack/deflater"
|
101
93
|
autoload :Directory, "rack/directory"
|
102
94
|
autoload :ForwardRequest, "rack/recursive"
|
@@ -105,11 +97,13 @@ module Rack
|
|
105
97
|
autoload :Lint, "rack/lint"
|
106
98
|
autoload :Lock, "rack/lock"
|
107
99
|
autoload :Logger, "rack/logger"
|
100
|
+
autoload :MediaType, "rack/media_type"
|
108
101
|
autoload :MethodOverride, "rack/method_override"
|
109
102
|
autoload :Mime, "rack/mime"
|
110
103
|
autoload :NullLogger, "rack/null_logger"
|
111
104
|
autoload :Recursive, "rack/recursive"
|
112
105
|
autoload :Reloader, "rack/reloader"
|
106
|
+
autoload :RewindableInput, "rack/rewindable_input"
|
113
107
|
autoload :Runtime, "rack/runtime"
|
114
108
|
autoload :Sendfile, "rack/sendfile"
|
115
109
|
autoload :Server, "rack/server"
|