devver-rack-contrib 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/COPYING +18 -0
  2. data/README.rdoc +80 -0
  3. data/Rakefile +90 -0
  4. data/lib/rack/contrib.rb +40 -0
  5. data/lib/rack/contrib/accept_format.rb +46 -0
  6. data/lib/rack/contrib/access.rb +85 -0
  7. data/lib/rack/contrib/backstage.rb +20 -0
  8. data/lib/rack/contrib/bounce_favicon.rb +16 -0
  9. data/lib/rack/contrib/callbacks.rb +37 -0
  10. data/lib/rack/contrib/config.rb +16 -0
  11. data/lib/rack/contrib/cookies.rb +50 -0
  12. data/lib/rack/contrib/csshttprequest.rb +39 -0
  13. data/lib/rack/contrib/deflect.rb +137 -0
  14. data/lib/rack/contrib/evil.rb +12 -0
  15. data/lib/rack/contrib/garbagecollector.rb +14 -0
  16. data/lib/rack/contrib/jsonp.rb +41 -0
  17. data/lib/rack/contrib/lighttpd_script_name_fix.rb +16 -0
  18. data/lib/rack/contrib/locale.rb +31 -0
  19. data/lib/rack/contrib/mailexceptions.rb +120 -0
  20. data/lib/rack/contrib/nested_params.rb +143 -0
  21. data/lib/rack/contrib/not_found.rb +18 -0
  22. data/lib/rack/contrib/post_body_content_type_parser.rb +40 -0
  23. data/lib/rack/contrib/proctitle.rb +30 -0
  24. data/lib/rack/contrib/profiler.rb +108 -0
  25. data/lib/rack/contrib/relative_redirect.rb +44 -0
  26. data/lib/rack/contrib/response_cache.rb +59 -0
  27. data/lib/rack/contrib/route_exceptions.rb +49 -0
  28. data/lib/rack/contrib/sendfile.rb +142 -0
  29. data/lib/rack/contrib/signals.rb +63 -0
  30. data/lib/rack/contrib/time_zone.rb +25 -0
  31. data/rack-contrib.gemspec +88 -0
  32. data/test/404.html +1 -0
  33. data/test/Maintenance.html +1 -0
  34. data/test/mail_settings.rb +12 -0
  35. data/test/spec_rack_accept_format.rb +72 -0
  36. data/test/spec_rack_access.rb +154 -0
  37. data/test/spec_rack_backstage.rb +26 -0
  38. data/test/spec_rack_callbacks.rb +65 -0
  39. data/test/spec_rack_config.rb +22 -0
  40. data/test/spec_rack_contrib.rb +8 -0
  41. data/test/spec_rack_csshttprequest.rb +66 -0
  42. data/test/spec_rack_deflect.rb +107 -0
  43. data/test/spec_rack_evil.rb +19 -0
  44. data/test/spec_rack_garbagecollector.rb +13 -0
  45. data/test/spec_rack_jsonp.rb +34 -0
  46. data/test/spec_rack_lighttpd_script_name_fix.rb +16 -0
  47. data/test/spec_rack_mailexceptions.rb +97 -0
  48. data/test/spec_rack_nested_params.rb +46 -0
  49. data/test/spec_rack_not_found.rb +17 -0
  50. data/test/spec_rack_post_body_content_type_parser.rb +32 -0
  51. data/test/spec_rack_proctitle.rb +26 -0
  52. data/test/spec_rack_profiler.rb +41 -0
  53. data/test/spec_rack_relative_redirect.rb +78 -0
  54. data/test/spec_rack_response_cache.rb +137 -0
  55. data/test/spec_rack_sendfile.rb +86 -0
  56. metadata +174 -0
@@ -0,0 +1,86 @@
1
+ require 'test/spec'
2
+ require 'rack/mock'
3
+ require 'rack/contrib/sendfile'
4
+
5
+ context "Rack::File" do
6
+ specify "should respond to #to_path" do
7
+ Rack::File.new(Dir.pwd).should.respond_to :to_path
8
+ end
9
+ end
10
+
11
+ context "Rack::Sendfile" do
12
+ def sendfile_body
13
+ res = ['Hello World']
14
+ def res.to_path ; "/tmp/hello.txt" ; end
15
+ res
16
+ end
17
+
18
+ def simple_app(body=sendfile_body)
19
+ lambda { |env| [200, {'Content-Type' => 'text/plain'}, body] }
20
+ end
21
+
22
+ def sendfile_app(body=sendfile_body)
23
+ Rack::Sendfile.new(simple_app(body))
24
+ end
25
+
26
+ setup do
27
+ @request = Rack::MockRequest.new(sendfile_app)
28
+ end
29
+
30
+ def request(headers={})
31
+ yield @request.get('/', headers)
32
+ end
33
+
34
+ specify "does nothing when no X-Sendfile-Type header present" do
35
+ request do |response|
36
+ response.should.be.ok
37
+ response.body.should.equal 'Hello World'
38
+ response.headers.should.not.include 'X-Sendfile'
39
+ end
40
+ end
41
+
42
+ specify "sets X-Sendfile response header and discards body" do
43
+ request 'HTTP_X_SENDFILE_TYPE' => 'X-Sendfile' do |response|
44
+ response.should.be.ok
45
+ response.body.should.be.empty
46
+ response.headers['X-Sendfile'].should.equal '/tmp/hello.txt'
47
+ end
48
+ end
49
+
50
+ specify "sets X-Lighttpd-Send-File response header and discards body" do
51
+ request 'HTTP_X_SENDFILE_TYPE' => 'X-Lighttpd-Send-File' do |response|
52
+ response.should.be.ok
53
+ response.body.should.be.empty
54
+ response.headers['X-Lighttpd-Send-File'].should.equal '/tmp/hello.txt'
55
+ end
56
+ end
57
+
58
+ specify "sets X-Accel-Redirect response header and discards body" do
59
+ headers = {
60
+ 'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect',
61
+ 'HTTP_X_ACCEL_MAPPING' => '/tmp/=/foo/bar/'
62
+ }
63
+ request headers do |response|
64
+ response.should.be.ok
65
+ response.body.should.be.empty
66
+ response.headers['X-Accel-Redirect'].should.equal '/foo/bar/hello.txt'
67
+ end
68
+ end
69
+
70
+ specify 'writes to rack.error when no X-Accel-Mapping is specified' do
71
+ request 'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect' do |response|
72
+ response.should.be.ok
73
+ response.body.should.equal 'Hello World'
74
+ response.headers.should.not.include 'X-Accel-Redirect'
75
+ response.errors.should.include 'X-Accel-Mapping'
76
+ end
77
+ end
78
+
79
+ specify 'does nothing when body does not respond to #to_path' do
80
+ @request = Rack::MockRequest.new(sendfile_app(['Not a file...']))
81
+ request 'HTTP_X_SENDFILE_TYPE' => 'X-Sendfile' do |response|
82
+ response.body.should.equal 'Not a file...'
83
+ response.headers.should.not.include 'X-Sendfile'
84
+ end
85
+ end
86
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devver-rack-contrib
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.3
5
+ platform: ruby
6
+ authors:
7
+ - rack-devel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-10 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.1
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: test-spec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.0
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: tmail
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "1.2"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: json
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "1.1"
54
+ version:
55
+ description: The Devver fork of rack-contrib
56
+ email: rack-devel@googlegroups.com
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - README.rdoc
63
+ - COPYING
64
+ files:
65
+ - COPYING
66
+ - README.rdoc
67
+ - Rakefile
68
+ - lib/rack/contrib.rb
69
+ - lib/rack/contrib/accept_format.rb
70
+ - lib/rack/contrib/access.rb
71
+ - lib/rack/contrib/backstage.rb
72
+ - lib/rack/contrib/bounce_favicon.rb
73
+ - lib/rack/contrib/callbacks.rb
74
+ - lib/rack/contrib/config.rb
75
+ - lib/rack/contrib/cookies.rb
76
+ - lib/rack/contrib/csshttprequest.rb
77
+ - lib/rack/contrib/deflect.rb
78
+ - lib/rack/contrib/evil.rb
79
+ - lib/rack/contrib/garbagecollector.rb
80
+ - lib/rack/contrib/jsonp.rb
81
+ - lib/rack/contrib/lighttpd_script_name_fix.rb
82
+ - lib/rack/contrib/locale.rb
83
+ - lib/rack/contrib/mailexceptions.rb
84
+ - lib/rack/contrib/nested_params.rb
85
+ - lib/rack/contrib/not_found.rb
86
+ - lib/rack/contrib/post_body_content_type_parser.rb
87
+ - lib/rack/contrib/proctitle.rb
88
+ - lib/rack/contrib/profiler.rb
89
+ - lib/rack/contrib/relative_redirect.rb
90
+ - lib/rack/contrib/response_cache.rb
91
+ - lib/rack/contrib/route_exceptions.rb
92
+ - lib/rack/contrib/sendfile.rb
93
+ - lib/rack/contrib/signals.rb
94
+ - lib/rack/contrib/time_zone.rb
95
+ - rack-contrib.gemspec
96
+ - test/404.html
97
+ - test/Maintenance.html
98
+ - test/mail_settings.rb
99
+ - test/spec_rack_accept_format.rb
100
+ - test/spec_rack_access.rb
101
+ - test/spec_rack_backstage.rb
102
+ - test/spec_rack_callbacks.rb
103
+ - test/spec_rack_config.rb
104
+ - test/spec_rack_contrib.rb
105
+ - test/spec_rack_csshttprequest.rb
106
+ - test/spec_rack_deflect.rb
107
+ - test/spec_rack_evil.rb
108
+ - test/spec_rack_garbagecollector.rb
109
+ - test/spec_rack_jsonp.rb
110
+ - test/spec_rack_lighttpd_script_name_fix.rb
111
+ - test/spec_rack_mailexceptions.rb
112
+ - test/spec_rack_nested_params.rb
113
+ - test/spec_rack_not_found.rb
114
+ - test/spec_rack_post_body_content_type_parser.rb
115
+ - test/spec_rack_proctitle.rb
116
+ - test/spec_rack_profiler.rb
117
+ - test/spec_rack_relative_redirect.rb
118
+ - test/spec_rack_response_cache.rb
119
+ - test/spec_rack_sendfile.rb
120
+ has_rdoc: true
121
+ homepage: http://github.com/rack/rack-contrib/
122
+ licenses: []
123
+
124
+ post_install_message:
125
+ rdoc_options:
126
+ - --line-numbers
127
+ - --inline-source
128
+ - --title
129
+ - rack-contrib
130
+ - --main
131
+ - README
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: "0"
139
+ version:
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: "0"
145
+ version:
146
+ requirements: []
147
+
148
+ rubyforge_project:
149
+ rubygems_version: 1.3.5
150
+ signing_key:
151
+ specification_version: 2
152
+ summary: This gem is the Devver fork of rack-contrib (http://github.com/rack/rack-contrib) so we can play around with new features we're building. You should not use this version and use the official rack-contrib gem instead.
153
+ test_files:
154
+ - test/spec_rack_accept_format.rb
155
+ - test/spec_rack_access.rb
156
+ - test/spec_rack_backstage.rb
157
+ - test/spec_rack_callbacks.rb
158
+ - test/spec_rack_config.rb
159
+ - test/spec_rack_contrib.rb
160
+ - test/spec_rack_csshttprequest.rb
161
+ - test/spec_rack_deflect.rb
162
+ - test/spec_rack_evil.rb
163
+ - test/spec_rack_garbagecollector.rb
164
+ - test/spec_rack_jsonp.rb
165
+ - test/spec_rack_lighttpd_script_name_fix.rb
166
+ - test/spec_rack_mailexceptions.rb
167
+ - test/spec_rack_nested_params.rb
168
+ - test/spec_rack_not_found.rb
169
+ - test/spec_rack_post_body_content_type_parser.rb
170
+ - test/spec_rack_proctitle.rb
171
+ - test/spec_rack_profiler.rb
172
+ - test/spec_rack_relative_redirect.rb
173
+ - test/spec_rack_response_cache.rb
174
+ - test/spec_rack_sendfile.rb