Created
January 18, 2011 03:16
-
-
Save joker1007/783922 to your computer and use it in GitHub Desktop.
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
--- cmdline-fu 2011-01-18 12:07:51.000000000 +0900 | |
+++ proxy/cmdline-fu 2011-01-18 12:04:02.000000000 +0900 | |
@@ -21,6 +21,7 @@ | |
class CommandLineFu | |
API_URL = 'http://www.commandlinefu.com/commands' | |
+ PROXY_HOST, PROXY_PORT = (ENV["HTTP_PROXY"] || '').sub(/http:\/\//, '').split(':') | |
# attr_reader :api_url | |
@@ -63,7 +64,7 @@ | |
def open_url(url) | |
uri = URI.parse(url) | |
- http = Net::HTTP.new(uri.host, uri.port) | |
+ http = Net::HTTP::Proxy(PROXY_HOST, PROXY_PORT).start(uri.host, uri.port) | |
request = Net::HTTP::Get.new(uri.request_uri) | |
http.request(request) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment