wallrj / https.py secret
Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View https.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
"""
(Twisted)[richard@zorin redux-4888]$ python docs/web/examples/https.py https://buildbot.twistedmatrix.com/json/builders/?as_text=1
...
],
"category": "supported",
"schedulers": [
"all",
"force-supported"
],
"slaves": [
"tomprince-socrates-winxp-1"
],
"state": "idle"
}
}
"""
 
 
from __future__ import print_function
import sys
from twisted.internet.task import react
from twisted.web.client import Agent, readBody, WebClientConnectionCreatorCreator
 
 
 
class HostnameOverrideWebClientConnectionCreatorCreator(WebClientConnectionCreatorCreator):
def __init__(self, *args, **kwargs):
self._expectedHostname = kwargs.pop('expectedHostname')
WebClientConnectionCreatorCreator.__init__(self, *args, **kwargs)
 
 
def creatorForNetloc(self, hostname, port):
return WebClientConnectionCreatorCreator.creatorForNetloc(self, self._expectedHostname, port)
 
 
 
 
def main(reactor):
cf = HostnameOverrideWebClientConnectionCreatorCreator(expectedHostname=u'www.twistedmatrix.com')
c = Agent(reactor=reactor, contextFactory=cf)
d = c.request('GET', sys.argv[1])
d.addCallback(readBody)
d.addCallback(print)
return d
 
 
 
react(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.