Permalink
Browse files

Add proxy support

  • Loading branch information...
1 parent c9215ec commit a54f84a4dbbb1e81331b080d74223f3d0bc09b73 @trico trico committed Dec 14, 2011
Showing with 13 additions and 2 deletions.
  1. +4 −2 Gist.sublime-settings
  2. +9 −0 gist.py
@@ -1,5 +1,7 @@
{
"create_public": "false",
"username": "YOUR_USERNAME",
- "password": "YOUR_PASSWORD"
-}
+ "password": "YOUR_PASSWORD",
+ "use_proxy": "false",
+ "proxy": "http://user:pass@proxy:port"
+}
View
@@ -26,6 +26,15 @@ def create_gist(description):
'Content-Length': len(data)}
request = urllib2.Request(url, data, headers)
+
+ if settings.get('use_proxy') :
+ opener = urllib2.build_opener(
+ urllib2.HTTPHandler(),
+ urllib2.HTTPSHandler(),
+ urllib2.ProxyHandler({'https': settings.get('proxy')})
+ )
+
+ urllib2.install_opener(opener)
response = urllib2.urlopen(request)
result = json.loads(response.read())

0 comments on commit a54f84a

Please sign in to comment.