Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Use a proxy to connect to librato. #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
7 changes: 6 additions & 1 deletion librato/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ def _setup_connection(self):
if self._do_we_want_to_fake_server_errors():
return HTTPSConnection(self.hostname, fake_n_errors=self.fake_n_errors)
else:
return HTTPSConnection(self.hostname, timeout=self.timeout)
conn = HTTPSConnection("proxy_host", "proxy_port", timeout=self.timeout)
auth = '%s:%s' % ("proxy_username", "proxy_password")
p_headers = {}
p_headers['Proxy-Authorization'] = 'Basic ' + base64.b64encode(auth)
conn.set_tunnel(HOSTNAME, 443, p_headers)
return conn

def _parse(self, resp, name, cls):
"""Parse to an object"""
Expand Down