I'm not quite sure if it fits into the users group, but I'll give it a
shot: I did a q'n'd hack adding basic proxy support to the
RemoteFileLoader task. Here's the diff:
lib/tasks/remote_file_loader.rb
6a7,15
>
> # Net::HTTP::Proxy returns a standard Net::HTTP Object
> # if host is nil so we can just go this way
> proxy_uri = URI.parse(ENV['HTTP_PROXY'].to_s)
> if proxy_uri.host
> print("Using proxy at #{proxy_uri.host}, port #{proxy_uri.port.to_s} (from HTTP_PROXY environment variable)\n")
> end
> proxy_user, proxy_pass = proxy_uri.userinfo.split(/:/) if proxy_uri.userinfo
> http_object = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_user, proxy_pass)
17c26
< response = Net::HTTP.get_response(uri.host, uri.path)
---
> response = http_object.get_response(uri.host, uri.path)
Hope this is as useful for some folks as it is for me ;) ...
Cheers
Herb
> response = http_object.get_response( uri.host, uri.path)
Just did a quick check on the remote_fetcher.rb code from RubyGems
source itself:
# Returns an HTTP proxy URI if one is set in the environment
variables.
def get_proxy_from_env
env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
uri = env_proxy ? URI.parse(env_proxy) : nil
if uri and uri.user.nil? and uri.password.nil? then
# Probably we have http_proxy_* variables?
uri.user = escape(ENV['http_proxy_user'] ||
ENV['HTTP_PROXY_USER'])
uri.password = escape(ENV['http_proxy_pass'] ||
ENV['HTTP_PROXY_PASS'])
end
uri
end
As I mentioned my code is really qnd and looking at above method,
there's definately some more work to be done like escaping, explicitly
checking for nil objects and so on.
I thought about messing with the download progress issue anyway, so
maybe we can kill two birds with one stone on this one...
And thanks for providing asunit and asproject ;)
Cheers
Herb
Yes, the ENV object is the standard way in ruby to access environment
variables across platforms.
Just did a quick check on the remote_fetcher.rb code from RubyGems
source itself:
# Returns an HTTP proxy URI if one is set in the environment
variables.
def get_proxy_from_env
env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
uri = env_proxy ? URI.parse(env_proxy) : nil
if uri and uri.user.nil? and uri.password.nil ? then