Skip to content

Instantly share code, notes, and snippets.

@momo-lab
Created May 9, 2012 07:00
Show Gist options
  • Save momo-lab/2642555 to your computer and use it in GitHub Desktop.
Save momo-lab/2642555 to your computer and use it in GitHub Desktop.
HTTP_PROXY環境変数にProxy認証用のUser/Passの定義がある場合はそれを使用するようにする。(要open-uri)
def open_uri(uri, options = {}, &block)
uri = URI.parse(uri) until URI === uri
proxy = uri.find_proxy
unless proxy.nil?
if proxy.user.nil?
options[:proxy] = proxy
else
options[:proxy_http_basic_authentication] = [proxy, proxy.user, proxy.password]
end
end
open(uri, options, &block)
end
@momo-lab
Copy link
Author

find_proxyを利用する形に書き変えた

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment