method
quick
v1_9_3_392 -
Show latest stable
-
0 notes -
Class: Server
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
quick(req, res)
public
Hide source
# File lib/rubygems/server.rb, line 549 def quick(req, res) Gem::Specification.reset res['content-type'] = 'text/plain' add_date res case req.request_uri.path when %^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)-([0-9.]+)(-.*?)?\.gemspec\.rz$| then marshal_format, name, version, platform = $1, $2, $3, $4 specs = Gem::Specification.find_all_by_name name, version selector = [name, version, platform].map(&:inspect).join ' ' platform = if platform then Gem::Platform.new platform.sub(/^-/, '') else Gem::Platform::RUBY end specs = specs.select { |s| s.platform == platform } if specs.empty? then res.status = 404 res.body = "No gems found matching #{selector}" elsif specs.length > 1 then res.status = 500 res.body = "Multiple gems found matching #{selector}" elsif marshal_format then res['content-type'] = 'application/x-deflate' res.body << Gem.deflate(Marshal.dump(specs.first)) end else raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." end end