Skip to content

@wallrj /https.py secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
"""
(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.