Skip to content
This repository was archived by the owner on Sep 25, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions rubygems_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def initialize(env)
end

def run
logger.info "#{env["REQUEST_METHOD"]} #{env["PATH_INFO"]}"
logger.info "#{env["REQUEST_METHOD"]} #{env["REQUEST_URI"]}"

return update_specs if env["REQUEST_METHOD"] == "DELETE"

case env["PATH_INFO"]
case env["REQUEST_URI"]
when "/"
[200, {"Content-Type" => "text/html"}, [erb(:index)]]
else
Expand All @@ -36,7 +36,7 @@ def erb(view)
end

def server_url
env["rack.url_scheme"] + "://" + File.join(env["SERVER_NAME"], env["PATH_INFO"])
env["rack.url_scheme"] + "://" + File.join(env["SERVER_NAME"], env["REQUEST_URI"])
end

def rubygems_url(gemname)
Expand Down Expand Up @@ -116,19 +116,19 @@ def cached?
end

def specs?
env["PATH_INFO"] =~ /specs\..+\.gz$/
env["REQUEST_URI"] =~ /specs\..+\.gz$/
end

def filepath
if specs?
File.join(root_dir, env["PATH_INFO"])
File.join(root_dir, env["REQUEST_URI"])
else
File.join(cache_dir, env["PATH_INFO"])
File.join(cache_dir, env["REQUEST_URI"])
end
end

def url
File.join("http://rubygems.org", env["PATH_INFO"])
File.join("http://rubygems.org", env["REQUEST_URI"])
end

def update_specs
Expand Down