rack-contrib 2.0.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +12 -8
- data/lib/rack/contrib/access.rb +8 -6
- data/lib/rack/contrib/backstage.rb +5 -3
- data/lib/rack/contrib/bounce_favicon.rb +3 -1
- data/lib/rack/contrib/callbacks.rb +2 -0
- data/lib/rack/contrib/common_cookies.rb +19 -11
- data/lib/rack/contrib/config.rb +3 -15
- data/lib/rack/contrib/cookies.rb +2 -0
- data/lib/rack/contrib/csshttprequest.rb +12 -6
- data/lib/rack/contrib/deflect.rb +35 -33
- data/lib/rack/contrib/enforce_valid_encoding.rb +3 -1
- data/lib/rack/contrib/evil.rb +2 -0
- data/lib/rack/contrib/expectation_cascade.rb +5 -3
- data/lib/rack/contrib/garbagecollector.rb +2 -0
- data/lib/rack/contrib/host_meta.rb +3 -1
- data/lib/rack/contrib/json_body_parser.rb +94 -0
- data/lib/rack/contrib/jsonp.rb +12 -7
- data/lib/rack/contrib/lazy_conditional_get.rb +13 -4
- data/lib/rack/contrib/lighttpd_script_name_fix.rb +2 -0
- data/lib/rack/contrib/locale.rb +75 -30
- data/lib/rack/contrib/mailexceptions.rb +2 -0
- data/lib/rack/contrib/nested_params.rb +3 -1
- data/lib/rack/contrib/not_found.rb +3 -1
- data/lib/rack/contrib/post_body_content_type_parser.rb +50 -5
- data/lib/rack/contrib/printout.rb +3 -1
- data/lib/rack/contrib/proctitle.rb +2 -0
- data/lib/rack/contrib/profiler.rb +44 -17
- data/lib/rack/contrib/relative_redirect.rb +11 -5
- data/lib/rack/contrib/response_cache.rb +21 -9
- data/lib/rack/contrib/response_headers.rb +8 -2
- data/lib/rack/contrib/route_exceptions.rb +2 -0
- data/lib/rack/contrib/runtime.rb +3 -30
- data/lib/rack/contrib/signals.rb +6 -0
- data/lib/rack/contrib/simple_endpoint.rb +3 -1
- data/lib/rack/contrib/static_cache.rb +18 -7
- data/lib/rack/contrib/time_zone.rb +2 -0
- data/lib/rack/contrib/try_static.rb +2 -0
- data/lib/rack/contrib/version.rb +5 -0
- data/lib/rack/contrib.rb +3 -1
- metadata +13 -212
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
|
1
5
|
module Rack
|
2
6
|
|
3
7
|
#
|
@@ -48,6 +52,8 @@ module Rack
|
|
48
52
|
|
49
53
|
|
50
54
|
class StaticCache
|
55
|
+
HEADERS_KLASS = Rack.release < "3" ? Utils::HeaderHash : Headers
|
56
|
+
private_constant :HEADERS_KLASS
|
51
57
|
|
52
58
|
def initialize(app, options={})
|
53
59
|
@app = app
|
@@ -55,20 +61,21 @@ module Rack
|
|
55
61
|
@no_cache = {}
|
56
62
|
@urls.collect! do |url|
|
57
63
|
if url =~ /\*$/
|
58
|
-
url.sub
|
59
|
-
@no_cache[
|
64
|
+
url_prefix = url.sub(/\*$/, '')
|
65
|
+
@no_cache[url_prefix] = 1
|
66
|
+
url_prefix
|
67
|
+
else
|
68
|
+
url
|
60
69
|
end
|
61
|
-
url
|
62
70
|
end
|
63
71
|
root = options[:root] || Dir.pwd
|
64
|
-
@file_server = Rack::
|
72
|
+
@file_server = Rack::Files.new(root)
|
65
73
|
@cache_duration = options[:duration] || 1
|
66
74
|
@versioning_enabled = options.fetch(:versioning, true)
|
67
75
|
if @versioning_enabled
|
68
76
|
@version_regex = options.fetch(:version_regex, /-[\d.]+([.][a-zA-Z][\w]+)?$/)
|
69
77
|
end
|
70
78
|
@duration_in_seconds = self.duration_in_seconds
|
71
|
-
@duration_in_words = self.duration_in_words
|
72
79
|
end
|
73
80
|
|
74
81
|
def call(env)
|
@@ -80,17 +87,21 @@ module Rack
|
|
80
87
|
if @versioning_enabled
|
81
88
|
path.sub!(@version_regex, '\1')
|
82
89
|
end
|
90
|
+
|
83
91
|
status, headers, body = @file_server.call(env)
|
92
|
+
headers = HEADERS_KLASS.new.merge(headers)
|
93
|
+
|
84
94
|
if @no_cache[url].nil?
|
85
95
|
headers['Cache-Control'] ="max-age=#{@duration_in_seconds}, public"
|
86
|
-
headers['Expires'] =
|
96
|
+
headers['Expires'] = duration_in_words
|
87
97
|
end
|
98
|
+
headers['Date'] = Time.now.httpdate
|
88
99
|
[status, headers, body]
|
89
100
|
end
|
90
101
|
end
|
91
102
|
|
92
103
|
def duration_in_words
|
93
|
-
(Time.now + self.duration_in_seconds).
|
104
|
+
(Time.now.utc + self.duration_in_seconds).httpdate
|
94
105
|
end
|
95
106
|
|
96
107
|
def duration_in_seconds
|
data/lib/rack/contrib.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rack'
|
2
4
|
|
3
5
|
module Rack
|
@@ -24,6 +26,7 @@ module Rack
|
|
24
26
|
autoload :HostMeta, "rack/contrib/host_meta"
|
25
27
|
autoload :GarbageCollector, "rack/contrib/garbagecollector"
|
26
28
|
autoload :JSONP, "rack/contrib/jsonp"
|
29
|
+
autoload :JSONBodyParser, "rack/contrib/json_body_parser"
|
27
30
|
autoload :LazyConditionalGet, "rack/contrib/lazy_conditional_get"
|
28
31
|
autoload :LighttpdScriptNameFix, "rack/contrib/lighttpd_script_name_fix"
|
29
32
|
autoload :Locale, "rack/contrib/locale"
|
@@ -32,7 +35,6 @@ module Rack
|
|
32
35
|
autoload :ProcTitle, "rack/contrib/proctitle"
|
33
36
|
autoload :Profiler, "rack/contrib/profiler"
|
34
37
|
autoload :ResponseHeaders, "rack/contrib/response_headers"
|
35
|
-
autoload :Runtime, "rack/contrib/runtime"
|
36
38
|
autoload :Signals, "rack/contrib/signals"
|
37
39
|
autoload :SimpleEndpoint, "rack/contrib/simple_endpoint"
|
38
40
|
autoload :TimeZone, "rack/contrib/time_zone"
|
metadata
CHANGED
@@ -1,229 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rack-devel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: git-version-bump
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.15'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.15'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: github-release
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.1'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.1'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: i18n
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.6'
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: 0.6.8
|
79
|
-
type: :development
|
80
|
-
prerelease: false
|
81
|
-
version_requirements: !ruby/object:Gem::Requirement
|
82
|
-
requirements:
|
83
|
-
- - "~>"
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0.6'
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 0.6.8
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: json
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '2.0'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '2.0'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: mime-types
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '3.0'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '3.0'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: minitest
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '5.6'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '5.6'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: minitest-hooks
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '1.0'
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - "~>"
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '1.0'
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: mail
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "~>"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '2.3'
|
152
|
-
- - ">="
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
version: 2.6.4
|
155
|
-
type: :development
|
156
|
-
prerelease: false
|
157
|
-
version_requirements: !ruby/object:Gem::Requirement
|
158
|
-
requirements:
|
159
|
-
- - "~>"
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version: '2.3'
|
162
|
-
- - ">="
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
version: 2.6.4
|
165
|
-
- !ruby/object:Gem::Dependency
|
166
|
-
name: nbio-csshttprequest
|
167
|
-
requirement: !ruby/object:Gem::Requirement
|
168
|
-
requirements:
|
169
|
-
- - "~>"
|
170
|
-
- !ruby/object:Gem::Version
|
171
|
-
version: '1.0'
|
172
|
-
type: :development
|
173
|
-
prerelease: false
|
174
|
-
version_requirements: !ruby/object:Gem::Requirement
|
175
|
-
requirements:
|
176
|
-
- - "~>"
|
177
|
-
- !ruby/object:Gem::Version
|
178
|
-
version: '1.0'
|
179
|
-
- !ruby/object:Gem::Dependency
|
180
|
-
name: rake
|
181
|
-
requirement: !ruby/object:Gem::Requirement
|
182
|
-
requirements:
|
183
|
-
- - "~>"
|
184
|
-
- !ruby/object:Gem::Version
|
185
|
-
version: '10.4'
|
186
|
-
- - ">="
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
version: 10.4.2
|
189
|
-
type: :development
|
190
|
-
prerelease: false
|
191
|
-
version_requirements: !ruby/object:Gem::Requirement
|
192
|
-
requirements:
|
193
|
-
- - "~>"
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
version: '10.4'
|
196
|
-
- - ">="
|
197
|
-
- !ruby/object:Gem::Version
|
198
|
-
version: 10.4.2
|
199
|
-
- !ruby/object:Gem::Dependency
|
200
|
-
name: rdoc
|
201
|
-
requirement: !ruby/object:Gem::Requirement
|
202
|
-
requirements:
|
203
|
-
- - "~>"
|
204
|
-
- !ruby/object:Gem::Version
|
205
|
-
version: '5.0'
|
206
|
-
type: :development
|
207
|
-
prerelease: false
|
208
|
-
version_requirements: !ruby/object:Gem::Requirement
|
209
|
-
requirements:
|
210
|
-
- - "~>"
|
211
|
-
- !ruby/object:Gem::Version
|
212
|
-
version: '5.0'
|
213
|
-
- !ruby/object:Gem::Dependency
|
214
|
-
name: ruby-prof
|
215
|
-
requirement: !ruby/object:Gem::Requirement
|
216
|
-
requirements:
|
217
|
-
- - "~>"
|
218
|
-
- !ruby/object:Gem::Version
|
219
|
-
version: 0.13.0
|
220
|
-
type: :development
|
221
|
-
prerelease: false
|
222
|
-
version_requirements: !ruby/object:Gem::Requirement
|
223
|
-
requirements:
|
224
|
-
- - "~>"
|
225
|
-
- !ruby/object:Gem::Version
|
226
|
-
version: 0.13.0
|
26
|
+
version: '4'
|
227
27
|
description: Contributed Rack Middleware and Utilities
|
228
28
|
email: rack-devel@googlegroups.com
|
229
29
|
executables: []
|
@@ -250,6 +50,7 @@ files:
|
|
250
50
|
- lib/rack/contrib/expectation_cascade.rb
|
251
51
|
- lib/rack/contrib/garbagecollector.rb
|
252
52
|
- lib/rack/contrib/host_meta.rb
|
53
|
+
- lib/rack/contrib/json_body_parser.rb
|
253
54
|
- lib/rack/contrib/jsonp.rb
|
254
55
|
- lib/rack/contrib/lazy_conditional_get.rb
|
255
56
|
- lib/rack/contrib/lighttpd_script_name_fix.rb
|
@@ -271,11 +72,12 @@ files:
|
|
271
72
|
- lib/rack/contrib/static_cache.rb
|
272
73
|
- lib/rack/contrib/time_zone.rb
|
273
74
|
- lib/rack/contrib/try_static.rb
|
274
|
-
|
75
|
+
- lib/rack/contrib/version.rb
|
76
|
+
homepage: https://github.com/rack/rack-contrib/
|
275
77
|
licenses:
|
276
78
|
- MIT
|
277
79
|
metadata: {}
|
278
|
-
post_install_message:
|
80
|
+
post_install_message:
|
279
81
|
rdoc_options:
|
280
82
|
- "--line-numbers"
|
281
83
|
- "--inline-source"
|
@@ -296,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
296
98
|
- !ruby/object:Gem::Version
|
297
99
|
version: '0'
|
298
100
|
requirements: []
|
299
|
-
|
300
|
-
|
301
|
-
signing_key:
|
101
|
+
rubygems_version: 3.5.3
|
102
|
+
signing_key:
|
302
103
|
specification_version: 2
|
303
104
|
summary: Contributed Rack Middleware and Utilities
|
304
105
|
test_files: []
|