Use Rack::Utils.bytesize; pin to rack >= 1.0

This commit is contained in:
Simon Rozet 2009-05-23 16:43:03 +02:00
parent 428a1ec51d
commit 9de67b15c6
2 changed files with 2 additions and 12 deletions

View File

@ -43,7 +43,7 @@ module Sinatra
body = [body] if body.respond_to? :to_str
if body.respond_to?(:to_ary)
header["Content-Length"] = body.to_ary.
inject(0) { |len, part| len + part.bytesize }.to_s
inject(0) { |len, part| len + Rack::Utils.bytesize(part) }.to_s
end
[status.to_i, header.to_hash, body]
end
@ -1106,13 +1106,3 @@ module Sinatra
Default.helpers(*extensions, &block)
end
end
class String #:nodoc:
# Define String#each under 1.9 for Rack compatibility. This should be
# removed once Rack is fully 1.9 compatible.
alias_method :each, :each_line unless ''.respond_to? :each
# Define String#bytesize as an alias to String#length for Ruby 1.8.6 and
# earlier.
alias_method :bytesize, :length unless ''.respond_to? :bytesize
end

View File

@ -112,7 +112,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'
s.add_dependency 'rack', '>= 1.0'
s.add_development_dependency 'shotgun', '>= 0.2', '< 1.0'
s.add_development_dependency 'rack-test', '>= 0.3.0'