Ticket #1774: proxy_take2.patch
| File proxy_take2.patch, 1.8 KB (added by ghazel, 7 years ago) |
|---|
-
twisted\web\client.py
old new 201 201 202 202 def __init__(self, url, method='GET', postdata=None, headers=None, 203 203 agent="Twisted PageGetter", timeout=0, cookies=None, 204 followRedirect=1 ):204 followRedirect=1, proxy=None): 205 205 self.protocol.followRedirect = followRedirect 206 206 self.timeout = timeout 207 207 self.agent = agent 208 self.proxy = proxy 208 209 209 210 if cookies is None: 210 211 cookies = {} … … 236 237 self.scheme = scheme 237 238 self.host = host 238 239 self.port = port 239 self.path = path 240 if self.proxy: 241 self.path = "%s://%s:%s%s" % (self.scheme, 242 self.host, 243 self.port, 244 path) 245 else: 246 self.path = path 240 247 241 248 def buildProtocol(self, addr): 242 249 p = protocol.ClientFactory.buildProtocol(self, addr) … … 378 385 return scheme, host, port, path 379 386 380 387 381 def getPage(url, contextFactory=None, *args, **kwargs):388 def getPage(url, contextFactory=None, proxy=None, *args, **kwargs): 382 389 """Download a web page as a string. 383 390 384 391 Download a page. Return a deferred, which will callback with a … … 387 394 See HTTPClientFactory to see what extra args can be passed. 388 395 """ 389 396 scheme, host, port, path = _parse(url) 397 if proxy: 398 host, port = proxy.split(':') 399 port = int(port) 400 kwargs['proxy'] = proxy 390 401 factory = HTTPClientFactory(url, *args, **kwargs) 391 402 if scheme == 'https': 392 403 from twisted.internet import ssl
