Created
May 10, 2012 06:30
-
-
Save momo-lab/2651449 to your computer and use it in GitHub Desktop.
gistコマンドでProxy認証を使えるようにする差分。SSLのverifyがうまく動かなかったのでNONEにしてしまったので、なんとなくforkするのがはばかられる
This file contains hidden or 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
diff --git a/lib/gist.rb b/lib/gist.rb | |
index d0be256..2274d7e 100644 | |
--- a/lib/gist.rb | |
+++ b/lib/gist.rb | |
@@ -33,11 +33,17 @@ module Gist | |
PROXY = URI(ENV['HTTPS_PROXY']) | |
elsif ENV['HTTP_PROXY'] | |
PROXY = URI(ENV['HTTP_PROXY']) | |
+ elsif ENV['http_proxy'] | |
+ PROXY = URI(ENV['http_proxy']) | |
+ elsif ENV['https_proxy'] | |
+ PROXY = URI(ENV['https_proxy']) | |
else | |
PROXY = nil | |
end | |
PROXY_HOST = PROXY ? PROXY.host : nil | |
PROXY_PORT = PROXY ? PROXY.port : nil | |
+ PROXY_USERNAME = PROXY && PROXY.user ? PROXY.user : nil | |
+ PROXY_PASSWORD = PROXY && PROXY.password ? PROXY.password : nil | |
# Parses command line arguments and does what needs to be done. | |
def execute(*args) | |
@@ -127,15 +133,14 @@ module Gist | |
url = URI.parse(CREATE_URL) | |
if PROXY_HOST | |
- proxy = Net::HTTP::Proxy(PROXY_HOST, PROXY_PORT) | |
+ proxy = Net::HTTP::Proxy(PROXY_HOST, PROXY_PORT, PROXY_USERNAME, PROXY_PASSWORD) | |
http = proxy.new(url.host, url.port) | |
else | |
http = Net::HTTP.new(url.host, url.port) | |
end | |
http.use_ssl = true | |
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
- http.ca_file = ca_cert | |
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
req = Net::HTTP::Post.new(url.path) | |
req.body = JSON.generate(data(files, private_gist, description)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment