rack 1.5.0.beta.2 → 1.5.0

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.

@@ -482,6 +482,30 @@ run on port 11211) and memcache-client installed.
482
482
  * [SEC] Rack::Auth::AbstractRequest no longer symbolizes arbitrary strings
483
483
  * Fixed erroneous test case in the 1.3.x series
484
484
 
485
+ * January 21st, 2013: Thirty third public release 1.5.0
486
+ * Introduced hijack SPEC, for before-response and after-response hijacking
487
+ * SessionHash is no longer a Hash subclass
488
+ * Rack::File cache_control parameter is removed, in place of headers options
489
+ * Rack::Auth::AbstractRequest#scheme now yields strings, not symbols
490
+ * Rack::Utils cookie functions now format expires in RFC 2822 format
491
+ * Rack::File now has a default mime type
492
+ * rackup -b 'run Rack::File.new(".")', option provides command line configs
493
+ * Rack::Deflater will no longer double encode bodies
494
+ * Rack::Mime#match? provides convenience for Accept header matching
495
+ * Rack::Utils#q_values provides splitting for Accept headers
496
+ * Rack::Utils#best_q_match provides a helper for Accept headers
497
+ * Rack::Handler.pick provides convenience for finding available servers
498
+ * Puma added to the list of default servers (preferred over Webrick)
499
+ * Various middleware now correctly close body when replacing it
500
+ * Rack::Request#params is no longer persistent with only GET params
501
+ * Rack::Request#update_param and #delete_param provide persistent operations
502
+ * Rack::Request#trusted_proxy? now returns true for local unix sockets
503
+ * Rack::Response no longer forces Content-Types
504
+ * Rack::Sendfile provides local mapping configuration options
505
+ * Rack::Utils#rfc2109 provides old netscape style time output
506
+ * Updated HTTP status codes
507
+ * Ruby 1.8.6 likely no longer passes tests, and is no longer fully supported
508
+
485
509
  == Contact
486
510
 
487
511
  Please post bugs, suggestions and patches to
@@ -304,8 +304,8 @@ module Rack
304
304
  middleware[options[:environment]].reverse_each do |middleware|
305
305
  middleware = middleware.call(self) if middleware.respond_to?(:call)
306
306
  next unless middleware
307
- klass = middleware.shift
308
- app = klass.new(app, *middleware)
307
+ klass, *args = middleware
308
+ app = klass.new(app, *args)
309
309
  end
310
310
  app
311
311
  end
@@ -3,6 +3,7 @@ require 'fileutils'
3
3
  require 'set'
4
4
  require 'tempfile'
5
5
  require 'rack/multipart'
6
+ require 'time'
6
7
 
7
8
  major, minor, patch = RUBY_VERSION.split('.').map { |v| v.to_i }
8
9
 
@@ -70,7 +71,6 @@ module Rack
70
71
  (qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
71
72
  next if p.empty?
72
73
  k, v = p.split('=', 2).map(&unescaper)
73
- next unless k || v
74
74
 
75
75
  if cur = params[k]
76
76
  if cur.class == Array
@@ -250,8 +250,29 @@ module Rack
250
250
  domain = "; domain=" + value[:domain] if value[:domain]
251
251
  path = "; path=" + value[:path] if value[:path]
252
252
  max_age = "; max-age=" + value[:max_age] if value[:max_age]
253
- # According to RFC 2109, we need dashes here.
254
- # N.B.: cgi.rb uses spaces...
253
+ # There is an RFC mess in the area of date formatting for Cookies. Not
254
+ # only are there contradicting RFCs and examples within RFC text, but
255
+ # there are also numerous conflicting names of fields and partially
256
+ # cross-applicable specifications.
257
+ #
258
+ # These are best described in RFC 2616 3.3.1. This RFC text also
259
+ # specifies that RFC 822 as updated by RFC 1123 is preferred. That is a
260
+ # fixed length format with space-date delimeted fields.
261
+ #
262
+ # See also RFC 1123 section 5.2.14.
263
+ #
264
+ # RFC 6265 also specifies "sane-cookie-date" as RFC 1123 date, defined
265
+ # in RFC 2616 3.3.1. RFC 6265 also gives examples that clearly denote
266
+ # the space delimited format. These formats are compliant with RFC 2822.
267
+ #
268
+ # For reference, all involved RFCs are:
269
+ # RFC 822
270
+ # RFC 1123
271
+ # RFC 2109
272
+ # RFC 2616
273
+ # RFC 2822
274
+ # RFC 2965
275
+ # RFC 6265
255
276
  expires = "; expires=" +
256
277
  rfc2822(value[:expires].clone.gmtime) if value[:expires]
257
278
  secure = "; secure" if value[:secure]
@@ -320,6 +341,11 @@ module Rack
320
341
  end
321
342
  module_function :bytesize
322
343
 
344
+ def rfc2822(time)
345
+ time.rfc2822
346
+ end
347
+ module_function :rfc2822
348
+
323
349
  # Modified version of stdlib time.rb Time#rfc2822 to use '%d-%b-%Y' instead
324
350
  # of '% %b %Y'.
325
351
  # It assumes that the time is in GMT to comply to the RFC 2109.
@@ -329,12 +355,12 @@ module Rack
329
355
  # Do not use %a and %b from Time.strptime, it would use localized names for
330
356
  # weekday and month.
331
357
  #
332
- def rfc2822(time)
358
+ def rfc2109(time)
333
359
  wday = Time::RFC2822_DAY_NAME[time.wday]
334
360
  mon = Time::RFC2822_MONTH_NAME[time.mon - 1]
335
361
  time.strftime("#{wday}, %d-#{mon}-%Y %H:%M:%S GMT")
336
362
  end
337
- module_function :rfc2822
363
+ module_function :rfc2109
338
364
 
339
365
  # Parses the "Range:" header, if present, into an array of Range objects.
340
366
  # Returns nil if the header is missing or syntactically invalid.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rack"
3
- s.version = "1.5.0.beta.2"
3
+ s.version = "1.5.0"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "a modular Ruby webserver interface"
6
6
 
@@ -65,12 +65,12 @@ describe Rack::Response do
65
65
  response["Set-Cookie"].should.equal ["foo=bar; domain=sample.example.com", "foo=bar; domain=.example.com"].join("\n")
66
66
  end
67
67
 
68
- it "formats the Cookie expiration date accordingly to RFC 2109" do
68
+ it "formats the Cookie expiration date accordingly to RFC 6265" do
69
69
  response = Rack::Response.new
70
70
 
71
71
  response.set_cookie "foo", {:value => "bar", :expires => Time.now+10}
72
72
  response["Set-Cookie"].should.match(
73
- /expires=..., \d\d-...-\d\d\d\d \d\d:\d\d:\d\d .../)
73
+ /expires=..., \d\d ... \d\d\d\d \d\d:\d\d:\d\d .../)
74
74
  end
75
75
 
76
76
  it "can set secure cookies" do
@@ -92,7 +92,7 @@ describe Rack::Response do
92
92
  response.delete_cookie "foo"
93
93
  response["Set-Cookie"].should.equal [
94
94
  "foo2=bar2",
95
- "foo=; max-age=0; expires=Thu, 01-Jan-1970 00:00:00 GMT"
95
+ "foo=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000"
96
96
  ].join("\n")
97
97
  end
98
98
 
@@ -102,10 +102,10 @@ describe Rack::Response do
102
102
  response.set_cookie "foo", {:value => "bar", :domain => ".example.com"}
103
103
  response["Set-Cookie"].should.equal ["foo=bar; domain=sample.example.com", "foo=bar; domain=.example.com"].join("\n")
104
104
  response.delete_cookie "foo", :domain => ".example.com"
105
- response["Set-Cookie"].should.equal ["foo=bar; domain=sample.example.com", "foo=; domain=.example.com; max-age=0; expires=Thu, 01-Jan-1970 00:00:00 GMT"].join("\n")
105
+ response["Set-Cookie"].should.equal ["foo=bar; domain=sample.example.com", "foo=; domain=.example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000"].join("\n")
106
106
  response.delete_cookie "foo", :domain => "sample.example.com"
107
- response["Set-Cookie"].should.equal ["foo=; domain=.example.com; max-age=0; expires=Thu, 01-Jan-1970 00:00:00 GMT",
108
- "foo=; domain=sample.example.com; max-age=0; expires=Thu, 01-Jan-1970 00:00:00 GMT"].join("\n")
107
+ response["Set-Cookie"].should.equal ["foo=; domain=.example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000",
108
+ "foo=; domain=sample.example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000"].join("\n")
109
109
  end
110
110
 
111
111
  it "can delete cookies with the same name with different paths" do
@@ -117,7 +117,7 @@ describe Rack::Response do
117
117
 
118
118
  response.delete_cookie "foo", :path => "/path"
119
119
  response["Set-Cookie"].should.equal ["foo=bar; path=/",
120
- "foo=; path=/path; max-age=0; expires=Thu, 01-Jan-1970 00:00:00 GMT"].join("\n")
120
+ "foo=; path=/path; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000"].join("\n")
121
121
  end
122
122
 
123
123
  it "can do redirects" do
@@ -2,6 +2,7 @@ require 'fileutils'
2
2
  require 'rack/lint'
3
3
  require 'rack/sendfile'
4
4
  require 'rack/mock'
5
+ require 'tmpdir'
5
6
 
6
7
  describe Rack::File do
7
8
  should "respond to #to_path" do
@@ -11,9 +12,9 @@ end
11
12
 
12
13
  describe Rack::Sendfile do
13
14
  def sendfile_body
14
- FileUtils.touch "/tmp/rack_sendfile"
15
+ FileUtils.touch File.join(Dir.tmpdir, "rack_sendfile")
15
16
  res = ['Hello World']
16
- def res.to_path ; "/tmp/rack_sendfile" ; end
17
+ def res.to_path ; File.join(Dir.tmpdir, "rack_sendfile") ; end
17
18
  res
18
19
  end
19
20
 
@@ -50,7 +51,7 @@ describe Rack::Sendfile do
50
51
  response.should.be.ok
51
52
  response.body.should.be.empty
52
53
  response.headers['Content-Length'].should.equal '0'
53
- response.headers['X-Sendfile'].should.equal '/tmp/rack_sendfile'
54
+ response.headers['X-Sendfile'].should.equal File.join(Dir.tmpdir, "rack_sendfile")
54
55
  end
55
56
  end
56
57
 
@@ -59,14 +60,14 @@ describe Rack::Sendfile do
59
60
  response.should.be.ok
60
61
  response.body.should.be.empty
61
62
  response.headers['Content-Length'].should.equal '0'
62
- response.headers['X-Lighttpd-Send-File'].should.equal '/tmp/rack_sendfile'
63
+ response.headers['X-Lighttpd-Send-File'].should.equal File.join(Dir.tmpdir, "rack_sendfile")
63
64
  end
64
65
  end
65
66
 
66
67
  it "sets X-Accel-Redirect response header and discards body" do
67
68
  headers = {
68
69
  'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect',
69
- 'HTTP_X_ACCEL_MAPPING' => '/tmp/=/foo/bar/'
70
+ 'HTTP_X_ACCEL_MAPPING' => "#{Dir.tmpdir}/=/foo/bar/"
70
71
  }
71
72
  request headers do |response|
72
73
  response.should.be.ok
@@ -365,6 +365,14 @@ describe Rack::Utils do
365
365
  should "return status code for symbol" do
366
366
  Rack::Utils.status_code(:ok).should.equal 200
367
367
  end
368
+
369
+ should "return rfc2822 format from rfc2822 helper" do
370
+ Rack::Utils.rfc2822(Time.at(0).gmtime).should == "Thu, 01 Jan 1970 00:00:00 -0000"
371
+ end
372
+
373
+ should "return rfc2109 format from rfc2109 helper" do
374
+ Rack::Utils.rfc2109(Time.at(0).gmtime).should == "Thu, 01-Jan-1970 00:00:00 GMT"
375
+ end
368
376
  end
369
377
 
370
378
  describe Rack::Utils, "byte_range" do
metadata CHANGED
@@ -1,70 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack
3
- version: !ruby/object:Gem::Version
4
- hash: 2837564799
5
- prerelease: 6
6
- segments:
7
- - 1
8
- - 5
9
- - 0
10
- - beta
11
- - 2
12
- version: 1.5.0.beta.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.0
5
+ prerelease:
13
6
  platform: ruby
14
- authors:
7
+ authors:
15
8
  - Christian Neukirchen
16
9
  autorequire:
17
10
  bindir: bin
18
11
  cert_chain: []
19
-
20
- date: 2013-01-13 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
23
15
  name: bacon
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
26
17
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
34
22
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: rake
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
48
38
  type: :development
49
- version_requirements: *id002
50
- description: |
51
- Rack provides a minimal, modular and adaptable interface for developing
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! 'Rack provides a minimal, modular and adaptable interface for developing
47
+
52
48
  web applications in Ruby. By wrapping HTTP requests and responses in
49
+
53
50
  the simplest way possible, it unifies and distills the API for web
51
+
54
52
  servers, web frameworks, and software in between (the so-called
53
+
55
54
  middleware) into a single method call.
56
-
55
+
56
+
57
57
  Also see http://rack.github.com/.
58
58
 
59
+ '
59
60
  email: chneukirchen@gmail.com
60
- executables:
61
+ executables:
61
62
  - rackup
62
63
  extensions: []
63
-
64
- extra_rdoc_files:
64
+ extra_rdoc_files:
65
65
  - README.rdoc
66
66
  - KNOWN-ISSUES
67
- files:
67
+ files:
68
68
  - bin/rackup
69
69
  - contrib/rack.png
70
70
  - contrib/rack.svg
@@ -239,40 +239,29 @@ files:
239
239
  - SPEC
240
240
  homepage: http://rack.github.com/
241
241
  licenses: []
242
-
243
242
  post_install_message:
244
243
  rdoc_options: []
245
-
246
- require_paths:
244
+ require_paths:
247
245
  - lib
248
- required_ruby_version: !ruby/object:Gem::Requirement
246
+ required_ruby_version: !ruby/object:Gem::Requirement
249
247
  none: false
250
- requirements:
251
- - - ">="
252
- - !ruby/object:Gem::Version
253
- hash: 3
254
- segments:
255
- - 0
256
- version: "0"
257
- required_rubygems_version: !ruby/object:Gem::Requirement
248
+ requirements:
249
+ - - ! '>='
250
+ - !ruby/object:Gem::Version
251
+ version: '0'
252
+ required_rubygems_version: !ruby/object:Gem::Requirement
258
253
  none: false
259
- requirements:
260
- - - ">"
261
- - !ruby/object:Gem::Version
262
- hash: 25
263
- segments:
264
- - 1
265
- - 3
266
- - 1
267
- version: 1.3.1
254
+ requirements:
255
+ - - ! '>='
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
268
258
  requirements: []
269
-
270
259
  rubyforge_project: rack
271
- rubygems_version: 1.8.24
260
+ rubygems_version: 1.8.23
272
261
  signing_key:
273
262
  specification_version: 3
274
263
  summary: a modular Ruby webserver interface
275
- test_files:
264
+ test_files:
276
265
  - test/spec_auth_basic.rb
277
266
  - test/spec_auth_digest.rb
278
267
  - test/spec_body_proxy.rb
@@ -320,4 +309,3 @@ test_files:
320
309
  - test/spec_urlmap.rb
321
310
  - test/spec_utils.rb
322
311
  - test/spec_webrick.rb
323
- has_rdoc: