Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: sinatra/sinatra
base: master
...
head fork: reinh/sinatra
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 5 commits
  • 3 files changed
  • 4 commit comments
  • 2 contributors
Commits on Apr 09, 2009
@reinh reinh Rack::Handler.get expects capitalized server names 5bade6a
@reinh reinh Tentatively Fix HEAD response Content-Length test
* Check Content-Length against the GET response Content-Length to ensure that
  they stay in sync against future updates to the way Rack constructs its
  request headers hash.

NOTE: HEAD response Content-Length seems to be off by 1 from equivalent GET
response Content-Length. This matches the current (0.9.1.1) behavior but
may no be intended.
3f8e8f1
@reinh reinh Rewrite Base#nested_params for Rack 1.0 nested params
Nested_params now recursively creates a nested indifferent hash from the
already nested hash provided by Rack 1.0
3b4af62
@reinh reinh Update rack gem dependency to allow rack 1.0 fa8dc93
ReinH Base#nested params now backwards compat with Rack 0.9.x 62ae8fc
Showing with 23 additions and 12 deletions.
  1. +17 −10 lib/sinatra/base.rb
  2. +1 −1  sinatra.gemspec
  3. +5 −1 test/test_test.rb
View
27 lib/sinatra/base.rb
@@ -470,17 +470,24 @@ def route_missing
end
end
+ # Recursively replace the params hash with a nested indifferent hash
def nested_params(params)
- return indifferent_hash.merge(params) if !params.keys.join.include?('[')
- params.inject indifferent_hash do |res, (key,val)|
- if key.include?('[')
- head = key.split(/[\]\[]+/)
- last = head.pop
- head.inject(res){ |hash,k| hash[k] ||= indifferent_hash }[last] = val
- else
- res[key] = val
+ params = indifferent_hash.merge(params)
+ if params.keys.join.include?('[')
+ params.inject indifferent_hash do |res, (key,val)|
+ if key.include?('[')
+ head = key.split(/[\]\[]+/)
+ last = head.pop
+ head.inject(res){ |hash,k| hash[k] ||= indifferent_hash }[last] = val
+ else
+ res[key] = val
+ end
+ res
+ end
+ else
+ params.each do |key, value|
+ params[key] = Hash === value ? nested_params(value) : value
end
- res
end
end
@@ -882,7 +889,7 @@ def detect_rack_handler
servers = Array(self.server)
servers.each do |server_name|
begin
- return Rack::Handler.get(server_name)
+ return Rack::Handler.get(server_name.capitalize)
rescue LoadError
rescue NameError
end
View
2  sinatra.gemspec
@@ -103,7 +103,7 @@ Gem::Specification.new do |s|
s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/}
s.extra_rdoc_files = %w[README.rdoc LICENSE]
- s.add_dependency 'rack', '>= 0.9.1', '< 1.0'
+ s.add_dependency 'rack', '>= 0.9.1'
s.add_development_dependency 'shotgun', '>= 0.2', '< 1.0'
s.has_rdoc = true
View
6 test/test_test.rb
@@ -35,6 +35,10 @@ def request_params
get '/'
assert_equal('GET', request['REQUEST_METHOD'])
+ # FIXME: This indicates that the HEAD response has a Content-Length one
+ # greater than the GET reponse. This seems incorrect
+ get_body_size = response.body.size + 1
+
post '/'
assert_equal('POST', request['REQUEST_METHOD'])
@@ -45,7 +49,7 @@ def request_params
assert_equal('DELETE', request['REQUEST_METHOD'])
head '/'
- assert_equal('596', response.headers['Content-Length'])
+ assert_equal(get_body_size.to_s, response.headers['Content-Length'])
assert_equal('', response.body)
end

Showing you all comments on commits in this comparison.

@rtomayko

I think we’ll probably just drop our nested params implementation all together and use Rack’s.

@rtomayko

Good idea. I’ll make sure this goes out in the next Sinatra 0.9.x release.

@rtomayko

Hmm. Definitely something funny going on there. Smells like a chars vs. bytes and bytesize vs. length issue.

@reinh

That was my original plan. (You can revert this commit and use a previous commit, which drops sinatra’s nested params implementatin). My concern was for Rack 0.9.x backwards compatibility.

Something went wrong with that request. Please try again.