Reviewers: mp+134896_code.launchpad.net, Message: Please take a look.
Description: client: add support for http and https proxying https://code.launchpad.net/~franciscosouza/txaws/txaws-proxysupport/+merge/134896 (do not edit description out of merge proposal) Please review this at https://codereview.appspot.com/6852064/ Affected files: A [revision details] M txaws/client/base.py Index: [revision details] === added file '[revision details]' --- [revision details] 2012-01-01 00:00:00 +0000 +++ [revision details] 2012-01-01 00:00:00 +0000 @@ -0,0 +1,2 @@ +Old revision: [email protected] +New revision: [email protected] Index: txaws/client/base.py === modified file 'txaws/client/base.py' --- txaws/client/base.py 2012-05-16 02:35:26 +0000 +++ txaws/client/base.py 2012-11-19 12:56:26 +0000 @@ -1,3 +1,6 @@ +import os +import urlparse + try: from xml.etree.ElementTree import ParseError except ImportError: @@ -6,14 +9,14 @@ import warnings from StringIO import StringIO +from twisted.internet.endpoints import TCP4ClientEndpoint from twisted.internet.ssl import ClientContextFactory from twisted.internet.protocol import Protocol from twisted.internet.defer import Deferred, succeed, fail from twisted.python import failure from twisted.web import http from twisted.web.iweb import UNKNOWN_LENGTH -from twisted.web.client import HTTPClientFactory -from twisted.web.client import Agent +from twisted.web.client import Agent, ProxyAgent from twisted.web.client import ResponseDone from twisted.web.http import NO_CONTENT from twisted.web.http_headers import Headers @@ -220,16 +223,28 @@ if (self.body_producer is None) and (data is not None): self.body_producer = FileBodyProducer(StringIO(data)) if scheme == "https": - if self.endpoint.ssl_hostname_verification: - contextFactory = WebVerifyingContextFactory(host) + proxy_endpoint = os.environ.get("https_proxy") + if proxy_endpoint: + proxy_url = urlparse.urlparse(proxy_endpoint) + endpoint = TCP4ClientEndpoint(self.reactor, proxy_url.hostname, proxy_url.port) + agent = ProxyAgent(endpoint, self.reactor) else: - contextFactory = WebClientContextFactory() - agent = Agent(self.reactor, contextFactory) + if self.endpoint.ssl_hostname_verification: + contextFactory = WebVerifyingContextFactory(host) + else: + contextFactory = WebClientContextFactory() + agent = Agent(self.reactor, contextFactory) self.client.url = url d = agent.request(method, url, self.request_headers, self.body_producer) else: - agent = Agent(self.reactor) + proxy_endpoint = os.environ.get("http_proxy") + if proxy_endpoint: + proxy_url = urlparse.urlparse(proxy_endpoint) + endpoint = TCP4ClientEndpoint(self.reactor, proxy_url.hostname, proxy_url.port) + agent = ProxyAgent(endpoint, self.reactor) + else: + agent = Agent(self.reactor) d = agent.request(method, url, self.request_headers, self.body_producer) d.addCallback(self._handle_response) -- https://code.launchpad.net/~franciscosouza/txaws/txaws-proxysupport/+merge/134896 Your team txAWS Committers is requested to review the proposed merge of lp:~franciscosouza/txaws/txaws-proxysupport into lp:txaws. _______________________________________________ Mailing list: https://launchpad.net/~txaws-dev Post to : [email protected] Unsubscribe : https://launchpad.net/~txaws-dev More help : https://help.launchpad.net/ListHelp

