rack-contrib 1.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +27 -13
  3. data/lib/rack/contrib/access.rb +8 -6
  4. data/lib/rack/contrib/backstage.rb +5 -3
  5. data/lib/rack/contrib/bounce_favicon.rb +3 -1
  6. data/lib/rack/contrib/callbacks.rb +2 -0
  7. data/lib/rack/contrib/common_cookies.rb +19 -11
  8. data/lib/rack/contrib/config.rb +3 -15
  9. data/lib/rack/contrib/cookies.rb +2 -0
  10. data/lib/rack/contrib/csshttprequest.rb +12 -6
  11. data/lib/rack/contrib/deflect.rb +35 -33
  12. data/lib/rack/contrib/enforce_valid_encoding.rb +3 -1
  13. data/lib/rack/contrib/evil.rb +2 -0
  14. data/lib/rack/contrib/expectation_cascade.rb +5 -3
  15. data/lib/rack/contrib/garbagecollector.rb +2 -0
  16. data/lib/rack/contrib/host_meta.rb +3 -1
  17. data/lib/rack/contrib/json_body_parser.rb +94 -0
  18. data/lib/rack/contrib/jsonp.rb +21 -17
  19. data/lib/rack/contrib/lazy_conditional_get.rb +13 -4
  20. data/lib/rack/contrib/lighttpd_script_name_fix.rb +2 -0
  21. data/lib/rack/contrib/locale.rb +74 -22
  22. data/lib/rack/contrib/mailexceptions.rb +3 -1
  23. data/lib/rack/contrib/nested_params.rb +6 -115
  24. data/lib/rack/contrib/not_found.rb +22 -7
  25. data/lib/rack/contrib/post_body_content_type_parser.rb +54 -4
  26. data/lib/rack/contrib/printout.rb +3 -1
  27. data/lib/rack/contrib/proctitle.rb +2 -0
  28. data/lib/rack/contrib/profiler.rb +44 -17
  29. data/lib/rack/contrib/relative_redirect.rb +11 -5
  30. data/lib/rack/contrib/response_cache.rb +23 -11
  31. data/lib/rack/contrib/response_headers.rb +8 -2
  32. data/lib/rack/contrib/route_exceptions.rb +2 -0
  33. data/lib/rack/contrib/runtime.rb +3 -30
  34. data/lib/rack/contrib/signals.rb +6 -0
  35. data/lib/rack/contrib/simple_endpoint.rb +3 -1
  36. data/lib/rack/contrib/static_cache.rb +20 -9
  37. data/lib/rack/contrib/time_zone.rb +2 -0
  38. data/lib/rack/contrib/try_static.rb +2 -0
  39. data/lib/rack/contrib/version.rb +5 -0
  40. data/lib/rack/contrib.rb +10 -4
  41. metadata +14 -189
  42. data/lib/rack/contrib/accept_format.rb +0 -66
  43. data/lib/rack/contrib/sendfile.rb +0 -140
metadata CHANGED
@@ -1,203 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.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: 2015-07-31 00:00:00.000000000 Z
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: '1.4'
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: '1.4'
27
- - !ruby/object:Gem::Dependency
28
- name: git-version-bump
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.15'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.15'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.0'
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.4'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.4'
83
- - !ruby/object:Gem::Dependency
84
- name: json
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.8'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.8'
97
- - !ruby/object:Gem::Dependency
98
- name: minitest
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '5.6'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '5.6'
111
- - !ruby/object:Gem::Dependency
112
- name: minitest-hooks
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '1.0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '1.0'
125
- - !ruby/object:Gem::Dependency
126
- name: mail
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '2.3'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '2.3'
139
- - !ruby/object:Gem::Dependency
140
- name: nbio-csshttprequest
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '1.0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '1.0'
153
- - !ruby/object:Gem::Dependency
154
- name: rake
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '10.4'
160
- - - ">="
161
- - !ruby/object:Gem::Version
162
- version: 10.4.2
163
- type: :development
164
- prerelease: false
165
- version_requirements: !ruby/object:Gem::Requirement
166
- requirements:
167
- - - "~>"
168
- - !ruby/object:Gem::Version
169
- version: '10.4'
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- version: 10.4.2
173
- - !ruby/object:Gem::Dependency
174
- name: rdoc
175
- requirement: !ruby/object:Gem::Requirement
176
- requirements:
177
- - - "~>"
178
- - !ruby/object:Gem::Version
179
- version: '3.12'
180
- type: :development
181
- prerelease: false
182
- version_requirements: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - "~>"
185
- - !ruby/object:Gem::Version
186
- version: '3.12'
187
- - !ruby/object:Gem::Dependency
188
- name: ruby-prof
189
- requirement: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - "~>"
192
- - !ruby/object:Gem::Version
193
- version: 0.13.0
194
- type: :development
195
- prerelease: false
196
- version_requirements: !ruby/object:Gem::Requirement
197
- requirements:
198
- - - "~>"
199
- - !ruby/object:Gem::Version
200
- version: 0.13.0
26
+ version: '4'
201
27
  description: Contributed Rack Middleware and Utilities
202
28
  email: rack-devel@googlegroups.com
203
29
  executables: []
@@ -210,7 +36,6 @@ files:
210
36
  - COPYING
211
37
  - README.md
212
38
  - lib/rack/contrib.rb
213
- - lib/rack/contrib/accept_format.rb
214
39
  - lib/rack/contrib/access.rb
215
40
  - lib/rack/contrib/backstage.rb
216
41
  - lib/rack/contrib/bounce_favicon.rb
@@ -225,6 +50,7 @@ files:
225
50
  - lib/rack/contrib/expectation_cascade.rb
226
51
  - lib/rack/contrib/garbagecollector.rb
227
52
  - lib/rack/contrib/host_meta.rb
53
+ - lib/rack/contrib/json_body_parser.rb
228
54
  - lib/rack/contrib/jsonp.rb
229
55
  - lib/rack/contrib/lazy_conditional_get.rb
230
56
  - lib/rack/contrib/lighttpd_script_name_fix.rb
@@ -241,17 +67,17 @@ files:
241
67
  - lib/rack/contrib/response_headers.rb
242
68
  - lib/rack/contrib/route_exceptions.rb
243
69
  - lib/rack/contrib/runtime.rb
244
- - lib/rack/contrib/sendfile.rb
245
70
  - lib/rack/contrib/signals.rb
246
71
  - lib/rack/contrib/simple_endpoint.rb
247
72
  - lib/rack/contrib/static_cache.rb
248
73
  - lib/rack/contrib/time_zone.rb
249
74
  - lib/rack/contrib/try_static.rb
250
- homepage: http://github.com/rack/rack-contrib/
75
+ - lib/rack/contrib/version.rb
76
+ homepage: https://github.com/rack/rack-contrib/
251
77
  licenses:
252
78
  - MIT
253
79
  metadata: {}
254
- post_install_message:
80
+ post_install_message:
255
81
  rdoc_options:
256
82
  - "--line-numbers"
257
83
  - "--inline-source"
@@ -265,16 +91,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
91
  requirements:
266
92
  - - ">="
267
93
  - !ruby/object:Gem::Version
268
- version: '0'
94
+ version: 2.2.2
269
95
  required_rubygems_version: !ruby/object:Gem::Requirement
270
96
  requirements:
271
97
  - - ">="
272
98
  - !ruby/object:Gem::Version
273
99
  version: '0'
274
100
  requirements: []
275
- rubyforge_project:
276
- rubygems_version: 2.2.2
277
- signing_key:
101
+ rubygems_version: 3.5.3
102
+ signing_key:
278
103
  specification_version: 2
279
104
  summary: Contributed Rack Middleware and Utilities
280
105
  test_files: []
@@ -1,66 +0,0 @@
1
- module Rack
2
- #
3
- # CAUTION: THIS MIDDLEWARE IS DEPRECATED. DO NOT USE IT.
4
- #
5
- # This middleware is slated for removal as of rack-contrib 2.0.0, because
6
- # it is terribad. Applications should *always* use the `Accept` header to
7
- # detect response formats (when it is available), rather than ignoring
8
- # that and instead examining the extension of the request. We recommend
9
- # using the `rack-accept` gem for handling the `Accept` family of entity
10
- # request headers.
11
- #
12
- # A Rack middleware for automatically adding a <tt>format</tt> token at the end of the request path
13
- # when there is none. It can detect formats passed in the HTTP_ACCEPT header to populate this token.
14
- #
15
- # e.g.:
16
- # GET /some/resource HTTP/1.1
17
- # Accept: application/json
18
- # ->
19
- # GET /some/resource.json HTTP/1.1
20
- # Accept: application/json
21
- #
22
- # You can add custom types with this kind of function (taken from sinatra):
23
- # def mime(ext, type)
24
- # ext = ".#{ext}" unless ext.to_s[0] == ?.
25
- # Rack::Mime::MIME_TYPES[ext.to_s] = type
26
- # end
27
- # and then:
28
- # mime :json, 'application/json'
29
- #
30
- # Note: it does not take into account multiple media types in the Accept header.
31
- # The first media type takes precedence over all the others.
32
- #
33
- # MIT-License - Cyril Rohr
34
- #
35
- class AcceptFormat
36
- def self.deprecation_acknowledged
37
- @deprecation_acknowledged
38
- end
39
-
40
- def self.acknowledge_deprecation
41
- @deprecation_acknowledged = true
42
- end
43
-
44
- def initialize(app, default_extention = '.html')
45
- unless self.class.deprecation_acknowledged
46
- warn "Rack::AcceptFormat is DEPRECATED and will be removed in rack-contrib 2.0.0"
47
- warn "Please see this middleware's documentation for more info."
48
- end
49
- @ext = default_extention.to_s.strip
50
- @ext = ".#{@ext}" unless @ext[0] == ?.
51
- @app = app
52
- end
53
-
54
- def call(env)
55
- req = Rack::Request.new(env)
56
-
57
- if ::File.extname(req.path_info).empty?
58
- accept = env['HTTP_ACCEPT'].to_s.scan(/[^;,\s]*\/[^;,\s]*/)[0].to_s
59
- extension = Rack::Mime::MIME_TYPES.invert[accept] || @ext
60
- req.path_info = req.path_info.chomp('/') << "#{extension}"
61
- end
62
-
63
- @app.call(env)
64
- end
65
- end
66
- end
@@ -1,140 +0,0 @@
1
- require 'rack/file'
2
-
3
- module Rack
4
- class File #:nodoc:
5
- alias :to_path :path
6
- end
7
-
8
- # = Sendfile
9
- #
10
- # The Sendfile middleware intercepts responses whose body is being
11
- # served from a file and replaces it with a server specific X-Sendfile
12
- # header. The web server is then responsible for writing the file contents
13
- # to the client. This can dramatically reduce the amount of work required
14
- # by the Ruby backend and takes advantage of the web servers optimized file
15
- # delivery code.
16
- #
17
- # In order to take advantage of this middleware, the response body must
18
- # respond to +to_path+ and the request must include an X-Sendfile-Type
19
- # header. Rack::File and other components implement +to_path+ so there's
20
- # rarely anything you need to do in your application. The X-Sendfile-Type
21
- # header is typically set in your web servers configuration. The following
22
- # sections attempt to document
23
- #
24
- # === Nginx
25
- #
26
- # Nginx supports the X-Accel-Redirect header. This is similar to X-Sendfile
27
- # but requires parts of the filesystem to be mapped into a private URL
28
- # hierarachy.
29
- #
30
- # The following example shows the Nginx configuration required to create
31
- # a private "/files/" area, enable X-Accel-Redirect, and pass the special
32
- # X-Sendfile-Type and X-Accel-Mapping headers to the backend:
33
- #
34
- # location /files/ {
35
- # internal;
36
- # alias /var/www/;
37
- # }
38
- #
39
- # location / {
40
- # proxy_redirect false;
41
- #
42
- # proxy_set_header Host $host;
43
- # proxy_set_header X-Real-IP $remote_addr;
44
- # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
45
- #
46
- # proxy_set_header X-Sendfile-Type X-Accel-Redirect
47
- # proxy_set_header X-Accel-Mapping /files/=/var/www/;
48
- #
49
- # proxy_pass http://127.0.0.1:8080/;
50
- # }
51
- #
52
- # Note that the X-Sendfile-Type header must be set exactly as shown above. The
53
- # X-Accel-Mapping header should specify the name of the private URL pattern,
54
- # followed by an equals sign (=), followed by the location on the file system
55
- # that it maps to. The middleware performs a simple substitution on the
56
- # resulting path.
57
- #
58
- # See Also: http://wiki.codemongers.com/NginxXSendfile
59
- #
60
- # === lighttpd
61
- #
62
- # Lighttpd has supported some variation of the X-Sendfile header for some
63
- # time, although only recent version support X-Sendfile in a reverse proxy
64
- # configuration.
65
- #
66
- # $HTTP["host"] == "example.com" {
67
- # proxy-core.protocol = "http"
68
- # proxy-core.balancer = "round-robin"
69
- # proxy-core.backends = (
70
- # "127.0.0.1:8000",
71
- # "127.0.0.1:8001",
72
- # ...
73
- # )
74
- #
75
- # proxy-core.allow-x-sendfile = "enable"
76
- # proxy-core.rewrite-request = (
77
- # "X-Sendfile-Type" => (".*" => "X-Sendfile")
78
- # )
79
- # }
80
- #
81
- # See Also: http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModProxyCore
82
- #
83
- # === Apache
84
- #
85
- # X-Sendfile is supported under Apache 2.x using a separate module:
86
- #
87
- # http://tn123.ath.cx/mod_xsendfile/
88
- #
89
- # Once the module is compiled and installed, you can enable it using
90
- # XSendFile config directive:
91
- #
92
- # RequestHeader Set X-Sendfile-Type X-Sendfile
93
- # ProxyPassReverse / http://localhost:8001/
94
- # XSendFile on
95
-
96
- class Sendfile
97
- def initialize(app, variation=nil)
98
- @app = app
99
- @variation = variation
100
- end
101
-
102
- def call(env)
103
- status, headers, body = @app.call(env)
104
- if body.respond_to?(:to_path)
105
- case type = variation(env)
106
- when 'X-Accel-Redirect'
107
- path = ::File.expand_path(body.to_path)
108
- if url = map_accel_path(env, path)
109
- headers[type] = url
110
- body = []
111
- else
112
- env['rack.errors'] << "X-Accel-Mapping header missing"
113
- end
114
- when 'X-Sendfile', 'X-Lighttpd-Send-File'
115
- path = ::File.expand_path(body.to_path)
116
- headers[type] = path
117
- body = []
118
- when '', nil
119
- else
120
- env['rack.errors'] << "Unknown x-sendfile variation: '#{variation}'.\n"
121
- end
122
- end
123
- [status, headers, body]
124
- end
125
-
126
- private
127
- def variation(env)
128
- @variation ||
129
- env['sendfile.type'] ||
130
- env['HTTP_X_SENDFILE_TYPE']
131
- end
132
-
133
- def map_accel_path(env, file)
134
- if mapping = env['HTTP_X_ACCEL_MAPPING']
135
- internal, external = mapping.split('=', 2).map{ |p| p.strip }
136
- file.sub(/^#{internal}/i, external)
137
- end
138
- end
139
- end
140
- end