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.

Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +690 -0
  3. data/CONTRIBUTING.md +136 -0
  4. data/{COPYING → MIT-LICENSE} +4 -2
  5. data/README.rdoc +152 -148
  6. data/Rakefile +37 -23
  7. data/{SPEC → SPEC.rdoc} +29 -5
  8. data/bin/rackup +1 -0
  9. data/example/lobster.ru +2 -0
  10. data/example/protectedlobster.rb +3 -1
  11. data/example/protectedlobster.ru +2 -0
  12. data/lib/rack.rb +67 -73
  13. data/lib/rack/auth/abstract/handler.rb +3 -1
  14. data/lib/rack/auth/abstract/request.rb +1 -1
  15. data/lib/rack/auth/basic.rb +7 -4
  16. data/lib/rack/auth/digest/md5.rb +13 -11
  17. data/lib/rack/auth/digest/nonce.rb +6 -3
  18. data/lib/rack/auth/digest/params.rb +4 -2
  19. data/lib/rack/auth/digest/request.rb +5 -3
  20. data/lib/rack/body_proxy.rb +15 -14
  21. data/lib/rack/builder.rb +116 -23
  22. data/lib/rack/cascade.rb +28 -12
  23. data/lib/rack/chunked.rb +68 -20
  24. data/lib/rack/common_logger.rb +33 -25
  25. data/lib/rack/conditional_get.rb +20 -16
  26. data/lib/rack/config.rb +2 -0
  27. data/lib/rack/content_length.rb +8 -7
  28. data/lib/rack/content_type.rb +5 -4
  29. data/lib/rack/core_ext/regexp.rb +14 -0
  30. data/lib/rack/deflater.rb +59 -34
  31. data/lib/rack/directory.rb +84 -64
  32. data/lib/rack/etag.rb +5 -4
  33. data/lib/rack/events.rb +19 -20
  34. data/lib/rack/file.rb +4 -173
  35. data/lib/rack/files.rb +218 -0
  36. data/lib/rack/handler.rb +7 -2
  37. data/lib/rack/handler/cgi.rb +2 -3
  38. data/lib/rack/handler/fastcgi.rb +4 -4
  39. data/lib/rack/handler/lsws.rb +3 -3
  40. data/lib/rack/handler/scgi.rb +9 -8
  41. data/lib/rack/handler/thin.rb +3 -3
  42. data/lib/rack/handler/webrick.rb +15 -6
  43. data/lib/rack/head.rb +1 -1
  44. data/lib/rack/lint.rb +71 -25
  45. data/lib/rack/lobster.rb +10 -10
  46. data/lib/rack/lock.rb +2 -1
  47. data/lib/rack/logger.rb +2 -0
  48. data/lib/rack/media_type.rb +10 -5
  49. data/lib/rack/method_override.rb +4 -2
  50. data/lib/rack/mime.rb +9 -1
  51. data/lib/rack/mock.rb +97 -20
  52. data/lib/rack/multipart.rb +6 -4
  53. data/lib/rack/multipart/generator.rb +17 -13
  54. data/lib/rack/multipart/parser.rb +54 -56
  55. data/lib/rack/multipart/uploaded_file.rb +15 -7
  56. data/lib/rack/null_logger.rb +2 -0
  57. data/lib/rack/query_parser.rb +53 -28
  58. data/lib/rack/recursive.rb +7 -5
  59. data/lib/rack/reloader.rb +8 -4
  60. data/lib/rack/request.rb +220 -61
  61. data/lib/rack/response.rb +127 -44
  62. data/lib/rack/rewindable_input.rb +4 -3
  63. data/lib/rack/runtime.rb +6 -4
  64. data/lib/rack/sendfile.rb +13 -9
  65. data/lib/rack/server.rb +95 -24
  66. data/lib/rack/session/abstract/id.rb +36 -23
  67. data/lib/rack/session/cookie.rb +11 -12
  68. data/lib/rack/session/memcache.rb +4 -93
  69. data/lib/rack/session/pool.rb +5 -3
  70. data/lib/rack/show_exceptions.rb +21 -17
  71. data/lib/rack/show_status.rb +9 -9
  72. data/lib/rack/static.rb +23 -11
  73. data/lib/rack/tempfile_reaper.rb +1 -1
  74. data/lib/rack/urlmap.rb +12 -6
  75. data/lib/rack/utils.rb +98 -109
  76. data/lib/rack/version.rb +29 -0
  77. data/rack.gemspec +40 -28
  78. metadata +36 -177
  79. data/HISTORY.md +0 -505
  80. data/test/builder/an_underscore_app.rb +0 -5
  81. data/test/builder/anything.rb +0 -5
  82. data/test/builder/comment.ru +0 -4
  83. data/test/builder/end.ru +0 -5
  84. data/test/builder/line.ru +0 -1
  85. data/test/builder/options.ru +0 -2
  86. data/test/cgi/assets/folder/test.js +0 -1
  87. data/test/cgi/assets/fonts/font.eot +0 -1
  88. data/test/cgi/assets/images/image.png +0 -1
  89. data/test/cgi/assets/index.html +0 -1
  90. data/test/cgi/assets/javascripts/app.js +0 -1
  91. data/test/cgi/assets/stylesheets/app.css +0 -1
  92. data/test/cgi/lighttpd.conf +0 -26
  93. data/test/cgi/rackup_stub.rb +0 -6
  94. data/test/cgi/sample_rackup.ru +0 -5
  95. data/test/cgi/test +0 -9
  96. data/test/cgi/test+directory/test+file +0 -1
  97. data/test/cgi/test.fcgi +0 -9
  98. data/test/cgi/test.gz +0 -0
  99. data/test/cgi/test.ru +0 -5
  100. data/test/gemloader.rb +0 -10
  101. data/test/helper.rb +0 -34
  102. data/test/multipart/bad_robots +0 -259
  103. data/test/multipart/binary +0 -0
  104. data/test/multipart/content_type_and_no_filename +0 -6
  105. data/test/multipart/empty +0 -10
  106. data/test/multipart/fail_16384_nofile +0 -814
  107. data/test/multipart/file1.txt +0 -1
  108. data/test/multipart/filename_and_modification_param +0 -7
  109. data/test/multipart/filename_and_no_name +0 -6
  110. data/test/multipart/filename_with_encoded_words +0 -7
  111. data/test/multipart/filename_with_escaped_quotes +0 -6
  112. data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
  113. data/test/multipart/filename_with_null_byte +0 -7
  114. data/test/multipart/filename_with_percent_escaped_quotes +0 -6
  115. data/test/multipart/filename_with_single_quote +0 -7
  116. data/test/multipart/filename_with_unescaped_percentages +0 -6
  117. data/test/multipart/filename_with_unescaped_percentages2 +0 -6
  118. data/test/multipart/filename_with_unescaped_percentages3 +0 -6
  119. data/test/multipart/filename_with_unescaped_quotes +0 -6
  120. data/test/multipart/ie +0 -6
  121. data/test/multipart/invalid_character +0 -6
  122. data/test/multipart/mixed_files +0 -21
  123. data/test/multipart/nested +0 -10
  124. data/test/multipart/none +0 -9
  125. data/test/multipart/quoted +0 -15
  126. data/test/multipart/rack-logo.png +0 -0
  127. data/test/multipart/semicolon +0 -6
  128. data/test/multipart/text +0 -15
  129. data/test/multipart/three_files_three_fields +0 -31
  130. data/test/multipart/unity3d_wwwform +0 -11
  131. data/test/multipart/webkit +0 -32
  132. data/test/rackup/config.ru +0 -31
  133. data/test/registering_handler/rack/handler/registering_myself.rb +0 -8
  134. data/test/spec_auth_basic.rb +0 -89
  135. data/test/spec_auth_digest.rb +0 -260
  136. data/test/spec_body_proxy.rb +0 -85
  137. data/test/spec_builder.rb +0 -233
  138. data/test/spec_cascade.rb +0 -63
  139. data/test/spec_cgi.rb +0 -84
  140. data/test/spec_chunked.rb +0 -103
  141. data/test/spec_common_logger.rb +0 -95
  142. data/test/spec_conditional_get.rb +0 -103
  143. data/test/spec_config.rb +0 -23
  144. data/test/spec_content_length.rb +0 -86
  145. data/test/spec_content_type.rb +0 -46
  146. data/test/spec_deflater.rb +0 -375
  147. data/test/spec_directory.rb +0 -148
  148. data/test/spec_etag.rb +0 -108
  149. data/test/spec_events.rb +0 -133
  150. data/test/spec_fastcgi.rb +0 -85
  151. data/test/spec_file.rb +0 -264
  152. data/test/spec_handler.rb +0 -57
  153. data/test/spec_head.rb +0 -46
  154. data/test/spec_lint.rb +0 -515
  155. data/test/spec_lobster.rb +0 -59
  156. data/test/spec_lock.rb +0 -204
  157. data/test/spec_logger.rb +0 -24
  158. data/test/spec_media_type.rb +0 -42
  159. data/test/spec_method_override.rb +0 -110
  160. data/test/spec_mime.rb +0 -51
  161. data/test/spec_mock.rb +0 -359
  162. data/test/spec_multipart.rb +0 -722
  163. data/test/spec_null_logger.rb +0 -21
  164. data/test/spec_recursive.rb +0 -75
  165. data/test/spec_request.rb +0 -1407
  166. data/test/spec_response.rb +0 -510
  167. data/test/spec_rewindable_input.rb +0 -128
  168. data/test/spec_runtime.rb +0 -50
  169. data/test/spec_sendfile.rb +0 -125
  170. data/test/spec_server.rb +0 -193
  171. data/test/spec_session_abstract_id.rb +0 -31
  172. data/test/spec_session_abstract_session_hash.rb +0 -45
  173. data/test/spec_session_cookie.rb +0 -442
  174. data/test/spec_session_memcache.rb +0 -357
  175. data/test/spec_session_pool.rb +0 -247
  176. data/test/spec_show_exceptions.rb +0 -93
  177. data/test/spec_show_status.rb +0 -104
  178. data/test/spec_static.rb +0 -184
  179. data/test/spec_tempfile_reaper.rb +0 -64
  180. data/test/spec_thin.rb +0 -96
  181. data/test/spec_urlmap.rb +0 -237
  182. data/test/spec_utils.rb +0 -742
  183. data/test/spec_version.rb +0 -11
  184. data/test/spec_webrick.rb +0 -206
  185. data/test/static/another/index.html +0 -1
  186. data/test/static/foo.html +0 -1
  187. data/test/static/index.html +0 -1
  188. data/test/testrequest.rb +0 -78
  189. data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
  190. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +0 -7
data/Rakefile CHANGED
@@ -1,7 +1,10 @@
1
- # Rakefile for Rack. -*-ruby-*-
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 :default => [:test]
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 :dist => %w[chmod ChangeLog SPEC rdoc] do
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 :officialrelease_really => %w[SPEC dist gem] do
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 :changelog => %w[ChangeLog]
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
- file "SPEC" => 'lib/rack/lint.rb' do
74
- File.open("SPEC", "wb") { |file|
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
- desc "Run all the fast + platform agnostic tests"
84
- task :test => 'SPEC' do
85
- opts = ENV['TEST'] || ''
86
- specopts = ENV['TESTOPTS']
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
- sh "ruby -I./lib:./test -S minitest #{opts} #{specopts} test/gemloader.rb test/spec*.rb"
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 :ci => :test
105
+ task ci: :test
93
106
 
94
- task :gem => ["SPEC"] do
107
+ task gem: :spec do
95
108
  sh "gem build rack.gemspec"
96
109
  end
97
110
 
98
- task :doc => :rdoc
111
+ task doc: :rdoc
112
+
99
113
  desc "Generate RDoc documentation"
100
- task :rdoc => %w[ChangeLog SPEC] do
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 :pushdoc => %w[rdoc] do
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 :pushsite => %w[pushdoc] do
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"
@@ -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
- <a href="https://tools.ietf.org/html/rfc3875#section-4.1.18">
64
- RFC3875 section 4.1.18</a> for
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
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "rack"
4
5
  Rack::Server.start
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rack/lobster'
2
4
 
3
5
  use Rack::ShowExceptions
@@ -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 :app => pretty_protected_lobster, :Port => 9292
16
+ Rack::Server.start app: pretty_protected_lobster, Port: 9292
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rack/lobster'
2
4
 
3
5
  use Rack::ShowExceptions
@@ -1,7 +1,9 @@
1
- # Copyright (C) 2007, 2008, 2009, 2010 Christian Neukirchen <purl.org/net/chneukirchen>
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 COPYING or http://www.opensource.org/licenses/mit-license.php.
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
- module Rack
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
- HTTP_HOST = 'HTTP_HOST'.freeze
29
- HTTP_VERSION = 'HTTP_VERSION'.freeze
30
- HTTPS = 'HTTPS'.freeze
31
- PATH_INFO = 'PATH_INFO'.freeze
32
- REQUEST_METHOD = 'REQUEST_METHOD'.freeze
33
- REQUEST_PATH = 'REQUEST_PATH'.freeze
34
- SCRIPT_NAME = 'SCRIPT_NAME'.freeze
35
- QUERY_STRING = 'QUERY_STRING'.freeze
36
- SERVER_PROTOCOL = 'SERVER_PROTOCOL'.freeze
37
- SERVER_NAME = 'SERVER_NAME'.freeze
38
- SERVER_ADDR = 'SERVER_ADDR'.freeze
39
- SERVER_PORT = 'SERVER_PORT'.freeze
40
- CACHE_CONTROL = 'Cache-Control'.freeze
41
- CONTENT_LENGTH = 'Content-Length'.freeze
42
- CONTENT_TYPE = 'Content-Type'.freeze
43
- SET_COOKIE = 'Set-Cookie'.freeze
44
- TRANSFER_ENCODING = 'Transfer-Encoding'.freeze
45
- HTTP_COOKIE = 'HTTP_COOKIE'.freeze
46
- ETAG = 'ETag'.freeze
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'.freeze
50
- POST = 'POST'.freeze
51
- PUT = 'PUT'.freeze
52
- PATCH = 'PATCH'.freeze
53
- DELETE = 'DELETE'.freeze
54
- HEAD = 'HEAD'.freeze
55
- OPTIONS = 'OPTIONS'.freeze
56
- LINK = 'LINK'.freeze
57
- UNLINK = 'UNLINK'.freeze
58
- TRACE = 'TRACE'.freeze
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'.freeze
62
- RACK_TEMPFILES = 'rack.tempfiles'.freeze
63
- RACK_ERRORS = 'rack.errors'.freeze
64
- RACK_LOGGER = 'rack.logger'.freeze
65
- RACK_INPUT = 'rack.input'.freeze
66
- RACK_SESSION = 'rack.session'.freeze
67
- RACK_SESSION_OPTIONS = 'rack.session.options'.freeze
68
- RACK_SHOWSTATUS_DETAIL = 'rack.showstatus.detail'.freeze
69
- RACK_MULTITHREAD = 'rack.multithread'.freeze
70
- RACK_MULTIPROCESS = 'rack.multiprocess'.freeze
71
- RACK_RUNONCE = 'rack.run_once'.freeze
72
- RACK_URL_SCHEME = 'rack.url_scheme'.freeze
73
- RACK_HIJACK = 'rack.hijack'.freeze
74
- RACK_IS_HIJACK = 'rack.hijack?'.freeze
75
- RACK_HIJACK_IO = 'rack.hijack_io'.freeze
76
- RACK_RECURSIVE_INCLUDE = 'rack.recursive.include'.freeze
77
- RACK_MULTIPART_BUFFER_SIZE = 'rack.multipart.buffer_size'.freeze
78
- RACK_MULTIPART_TEMPFILE_FACTORY = 'rack.multipart.tempfile_factory'.freeze
79
- RACK_REQUEST_FORM_INPUT = 'rack.request.form_input'.freeze
80
- RACK_REQUEST_FORM_HASH = 'rack.request.form_hash'.freeze
81
- RACK_REQUEST_FORM_VARS = 'rack.request.form_vars'.freeze
82
- RACK_REQUEST_COOKIE_HASH = 'rack.request.cookie_hash'.freeze
83
- RACK_REQUEST_COOKIE_STRING = 'rack.request.cookie_string'.freeze
84
- RACK_REQUEST_QUERY_HASH = 'rack.request.query_hash'.freeze
85
- RACK_REQUEST_QUERY_STRING = 'rack.request.query_string'.freeze
86
- RACK_METHODOVERRIDE_ORIGINAL_METHOD = 'rack.methodoverride.original_method'.freeze
87
- RACK_SESSION_UNPACKED_COOKIE_DATA = 'rack.session.unpacked_cookie_data'.freeze
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"