Skip to content

Commit

Permalink
[webui] take care about http proxy settings on host for using gravata…
Browse files Browse the repository at this point in the history
…r (untested)
  • Loading branch information
adrianschroeter committed Oct 24, 2012
1 parent b454f73 commit a67d5ff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/webui/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ def icon
unless CONFIG['enable_gravatar'] == :off
email = Person.email_for_login(user)
hash = Digest::MD5.hexdigest(email.downcase)
http = Net::HTTP.new("www.gravatar.com")
http = nil
proxyuri = ENV['HTTP_PROXY']
proxyuri = CONFIG['HTTP_PROXY'] unless CONFIG['HTTP_PROXY'].blank?
if proxyuri
proxy = URI.parse(proxyuri)
proxy_user, proxy_pass = proxy.userinfo.split(/:/) if proxyuri.userinfo
http = Net::HTTP::Proxy(proxy.host, proxy.port, proxy_user, proxy_pass).new("www.gravatar.com")
else
http = Net::HTTP.new("www.gravatar.com")
end
begin
http.start
response = http.get "/avatar/#{hash}?s=#{size}&d=wavatar" unless Rails.env.test?
Expand Down

0 comments on commit a67d5ff

Please sign in to comment.