Merge lp://staging/~franciscosouza/txaws/txaws-proxysupport into lp://staging/txaws

Proposed by Francisco Souza
Status: Needs review
Proposed branch: lp://staging/~franciscosouza/txaws/txaws-proxysupport
Merge into: lp://staging/txaws
Diff against target: 73 lines (+24/-9)
1 file modified
txaws/client/base.py (+24/-9)
To merge this branch: bzr merge lp://staging/~franciscosouza/txaws/txaws-proxysupport
Reviewer Review Type Date Requested Status
txAWS Committers Pending
Review via email: mp+134896@code.staging.launchpad.net

Description of the change

client: add support for http and https proxying

https://codereview.appspot.com/6852064/

To post a comment you must log in.
Revision history for this message
Chico (franciscossouza) wrote :
Download full text (3.4 KiB)

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 address hidden>
+New revision: <email address hidden>

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 =...

Read more...

153. By Francisco Souza

client: don't pass reator to ProxyAgent

Endpoint already holds the instance of the reactor.

Revision history for this message
Chico (franciscossouza) wrote :
154. By Francisco Souza

client: trap PotentialDataLoss

Amazon never sends Content-Length header, even on http 1.0.

Revision history for this message
Chico (franciscossouza) wrote :

Unmerged revisions

154. By Francisco Souza

client: trap PotentialDataLoss

Amazon never sends Content-Length header, even on http 1.0.

153. By Francisco Souza

client: don't pass reator to ProxyAgent

Endpoint already holds the instance of the reactor.

152. By Francisco Souza

client: add support for http and https proxying

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches