Created
May 9, 2012 07:00
-
-
Save momo-lab/2642555 to your computer and use it in GitHub Desktop.
HTTP_PROXY環境変数にProxy認証用のUser/Passの定義がある場合はそれを使用するようにする。(要open-uri)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
find_proxyを利用する形に書き変えた