Skip to content

Instantly share code, notes, and snippets.


wallrj/ Secret

Created Apr 20, 2014
What would you like to do?
(Twisted)[richard@zorin redux-4888]$ python docs/web/examples/
"category": "supported",
"schedulers": [
"slaves": [
"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'')
c = Agent(reactor=reactor, contextFactory=cf)
d = c.request('GET', sys.argv[1])
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment