Skip to content

Instantly share code, notes, and snippets.

@joker1007
Created January 18, 2011 03:16
Show Gist options
  • Save joker1007/783922 to your computer and use it in GitHub Desktop.
Save joker1007/783922 to your computer and use it in GitHub Desktop.
--- 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