Commit 5e0612e3 authored by Sruthi Chandran's avatar Sruthi Chandran

New upstream version 2.0.5

parent 61a2d318
......@@ -228,7 +228,7 @@ You are also welcome to join the #rack channel on irc.freenode.net.
The Rack Core Team, consisting of
* Christian Neukirchen (chneukirchen[https://github.com/chneukirchen])
* Leah Neukirchen (chneukirchen[https://github.com/chneukirchen])
* James Tucker (raggi[https://github.com/raggi])
* Josh Peek (josh[https://github.com/josh])
* José Valim (josevalim[https://github.com/josevalim])
......@@ -295,10 +295,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
== Links
Rack:: <http://rack.github.io/>
Rack:: <https://rack.github.io/>
Official Rack repositories:: <https://github.com/rack>
Rack Bug Tracking:: <https://github.com/rack/rack/issues>
rack-devel mailing list:: <https://groups.google.com/group/rack-devel>
Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
Christian Neukirchen:: <http://chneukirchen.org/>
......@@ -18,7 +18,7 @@ module Rack
VERSION.join(".")
end
RELEASE = "2.0.3"
RELEASE = "2.0.5"
# Return the Rack release as a dotted string.
def self.release
......
......@@ -24,7 +24,7 @@ module Rack
size = chunk.bytesize
next if size == 0
chunk = chunk.dup.force_encoding(Encoding::BINARY)
chunk = chunk.b
yield [size.to_s(16), term, chunk, term].join
end
yield TAIL
......
require 'rack'
require 'digest/md5'
require 'digest/sha2'
module Rack
# Automatically sets the ETag header on all String bodies.
......
......@@ -11,12 +11,21 @@ module Rack
def call(env)
@mutex.lock
@env = env
@old_rack_multithread = env[RACK_MULTITHREAD]
begin
response = @app.call(env.merge(RACK_MULTITHREAD => false))
returned = response << BodyProxy.new(response.pop) { @mutex.unlock }
response = @app.call(env.merge!(RACK_MULTITHREAD => false))
returned = response << BodyProxy.new(response.pop) { unlock }
ensure
@mutex.unlock unless returned
unlock unless returned
end
end
private
def unlock
@mutex.unlock
@env[RACK_MULTITHREAD] = @old_rack_multithread
end
end
end
......@@ -26,7 +26,11 @@ module Rack
req = Request.new(env)
method = method_override_param(req) ||
env[HTTP_METHOD_OVERRIDE_HEADER]
method.to_s.upcase
begin
method.to_s.upcase
rescue ArgumentError
env[RACK_ERRORS].puts "Invalid string for method"
end
end
private
......
......@@ -128,7 +128,7 @@ module Rack
end
end
empty_str = String.new.force_encoding(Encoding::ASCII_8BIT)
empty_str = String.new
opts[:input] ||= empty_str
if String === opts[:input]
rack_input = StringIO.new(opts[:input])
......
......@@ -5,7 +5,7 @@ module Rack
class MultipartPartLimitError < Errno::EMFILE; end
class Parser
BUFSIZE = 16384
BUFSIZE = 1_048_576
TEXT_PLAIN = "text/plain"
TEMPFILE_FACTORY = lambda { |filename, content_type|
Tempfile.new(["RackMultipart", ::File.extname(filename.gsub("\0".freeze, '%00'.freeze))])
......@@ -135,7 +135,7 @@ module Rack
klass = TempfilePart
@open_files += 1
else
body = ''.force_encoding(Encoding::ASCII_8BIT)
body = String.new
klass = BufferPart
end
......@@ -165,15 +165,15 @@ module Rack
attr_reader :state
def initialize(boundary, tempfile, bufsize, query_parser)
@buf = "".force_encoding(Encoding::ASCII_8BIT)
@buf = String.new
@query_parser = query_parser
@params = query_parser.make_params
@boundary = "--#{boundary}"
@boundary_size = @boundary.bytesize + EOL.size
@bufsize = bufsize
@rx = /(?:#{EOL})?#{Regexp.quote(@boundary)}(#{EOL}|--)/n
@rx_max_size = EOL.size + @boundary.bytesize + [EOL.size, '--'.size].max
@full_boundary = @boundary
@end_boundary = @boundary + '--'
@state = :FAST_FORWARD
......@@ -263,15 +263,17 @@ module Rack
end
def handle_mime_body
if @buf =~ rx
if i = @buf.index(rx)
# Save the rest.
if i = @buf.index(rx)
@collector.on_mime_body @mime_index, @buf.slice!(0, i)
@buf.slice!(0, 2) # Remove \r\n after the content
end
@collector.on_mime_body @mime_index, @buf.slice!(0, i)
@buf.slice!(0, 2) # Remove \r\n after the content
@state = :CONSUME_TOKEN
@mime_index += 1
else
# Save the read body part.
if @rx_max_size < @buf.size
@collector.on_mime_body @mime_index, @buf.slice!(0, @buf.size - @rx_max_size)
end
:want_read
end
end
......
......@@ -12,7 +12,7 @@ the simplest way possible, it unifies and distills the API for web
servers, web frameworks, and software in between (the so-called
middleware) into a single method call.
Also see http://rack.github.io/.
Also see https://rack.github.io/.
EOF
s.files = Dir['{bin/*,contrib/*,example/*,lib/**/*,test/**/*}'] +
......@@ -23,13 +23,12 @@ EOF
s.extra_rdoc_files = ['README.rdoc', 'HISTORY.md']
s.test_files = Dir['test/spec_*.rb']
s.author = 'Christian Neukirchen'
s.email = 'chneukirchen@gmail.com'
s.homepage = 'http://rack.github.io/'
s.author = 'Leah Neukirchen'
s.email = 'leah@vuxu.org'
s.homepage = 'https://rack.github.io/'
s.required_ruby_version = '>= 2.2.2'
s.add_development_dependency 'minitest', "~> 5.0"
s.add_development_dependency 'minitest-sprint'
s.add_development_dependency 'concurrent-ruby'
s.add_development_dependency 'rake'
end
......@@ -147,7 +147,8 @@ describe Rack::Lock do
}, false)
env = Rack::MockRequest.env_for("/")
env['rack.multithread'].must_equal true
app.call(env)
_, _, body = app.call(env)
body.close
env['rack.multithread'].must_equal true
end
......@@ -191,4 +192,13 @@ describe Rack::Lock do
lambda { app.call(env) }.must_raise Exception
lock.synchronized.must_equal false
end
it "not replace the environment" do
env = Rack::MockRequest.env_for("/")
app = lock_app(lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, [inner_env.object_id.to_s]] })
_, _, body = app.call(env)
body.to_enum.to_a.must_equal [env.object_id.to_s]
end
end
......@@ -17,6 +17,20 @@ describe Rack::MethodOverride do
env["REQUEST_METHOD"].must_equal "GET"
end
it "sets rack.errors for invalid UTF8 _method values" do
errors = StringIO.new
env = Rack::MockRequest.env_for("/",
:method => "POST",
:input => "_method=\xBF".b,
Rack::RACK_ERRORS => errors)
app.call env
errors.rewind
errors.read.must_equal "Invalid string for method\n"
env["REQUEST_METHOD"].must_equal "POST"
end
it "modify REQUEST_METHOD for POST requests when _method parameter is set" do
env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=put")
app.call env
......
require 'minitest/autorun'
require 'rack/mock'
require 'concurrent/utility/native_integer'
require 'concurrent/atomic/count_down_latch'
require 'thread'
require File.expand_path('../testrequest', __FILE__)
Thread.abort_on_exception = true
......@@ -120,8 +119,7 @@ describe Rack::Handler::WEBrick do
end
it "provide a .run" do
block_ran = false
latch = Concurrent::CountDownLatch.new 1
queue = Queue.new
t = Thread.new do
Rack::Handler::WEBrick.run(lambda {},
......@@ -132,13 +130,12 @@ describe Rack::Handler::WEBrick do
:AccessLog => []}) { |server|
block_ran = true
assert_kind_of WEBrick::HTTPServer, server
@s = server
latch.count_down
queue.push(server)
}
end
latch.wait
@s.shutdown
server = queue.pop
server.shutdown
t.join
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment