Skip to content
Browse files

Add support for proxy to gem command. Uses standard http_proxy env to…

… detect proxy
  • Loading branch information...
1 parent db0d5de commit 02bc6f3d555feb80b18bbf553d79736273a61f6d Marcus Derencius committed with tomlea Aug 17, 2010
Showing with 10 additions and 2 deletions.
  1. +1 −1 geminabox.gemspec
  2. +9 −1 lib/rubygems/commands/inabox_command.rb
View
2 geminabox.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'geminabox'
- s.version = '0.2.6'
+ s.version = '0.2.7'
s.summary = 'Really simple rubygem hosting'
s.description = 'A sinatra based gem hosting app, with client side gem push style functionality.'
s.author = 'Tom Lea'
View
10 lib/rubygems/commands/inabox_command.rb
@@ -52,14 +52,22 @@ def send_gem
url = URI.parse(geminabox_host)
request_body, request_headers = Multipart::MultipartPost.new.prepare_query("file" => file)
- Net::HTTP.start(url.host, url.port) {|con|
+ proxy.start(url.host, url.port) {|con|
req = Net::HTTP::Post.new('/upload', request_headers)
req.basic_auth(url.user, url.password) if url.user
handle_response(con.request(req, request_body))
}
end
end
+ def proxy
+ if proxy_info = ENV['http_proxy'] || ENV['HTTP_PROXY'] and uri = URI.parse(proxy_info)
+ Net::HTTP::Proxy(uri.host, uri.port, uri.user, uri.password)
+ else
+ Net::HTTP
+ end
+ end
+
def handle_response(response)
case response
when Net::HTTPSuccess, Net::HTTPRedirection

0 comments on commit 02bc6f3

Please sign in to comment.
Something went wrong with that request. Please try again.