Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions cloudprint/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import UserDict
import UserList
import UserString
import os
from urlparse import urlparse

class REST:
class RESTException(Exception):
Expand Down Expand Up @@ -41,10 +43,22 @@ def __repr__(self):

def __init__(self, host, auth=None, debug=False):
proto, host = host.split('://')
if proto == 'https':
self._conn = httplib.HTTPSConnection(host)

http_proxy = os.environ.get('http_proxy')
if http_proxy is not None:
proxy= urlparse(http_proxy)
if proto == 'https':
c = httplib.HTTPSConnection(proxy.hostname, proxy.port)
else:
c = httplib.HTTPConnection(proxy.hostname, proxy.port)
c.set_tunnel(host)
self._conn = c
else:
self._conn = httplib.HTTPConnection(host)
if proto == 'https':
self._conn = httplib.HTTPSConnection(host)
else:
self._conn = httplib.HTTPConnection(host)

self.debug = debug
if debug:
self._conn.set_debuglevel(10)
Expand Down