def setUp(self): self.agent = None # for twisted.web.client.Agent test self.cleanupServerConnections = 0 r = resource.Resource() r.putChild(b"file", Data(b"0123456789", b"text/html")) r.putChild(b"redirect", Redirect(b"/file")) self.infiniteRedirectResource = CountingRedirect(b"/infiniteRedirect") r.putChild(b"infiniteRedirect", self.infiniteRedirectResource) r.putChild(b"wait", ForeverTakingResource()) r.putChild(b"write-then-wait", ForeverTakingResource(write=True)) r.putChild(b"error", ErrorResource()) r.putChild(b"nolength", NoLengthResource()) r.putChild(b"host", HostHeaderResource()) r.putChild(b"payload", PayloadResource()) r.putChild(b"broken", BrokenDownloadResource()) r.putChild(b"cookiemirror", CookieMirrorResource()) r.putChild(b"delay1", DelayResource(1)) r.putChild(b"delay2", DelayResource(2)) self.afterFoundGetCounter = CountingResource() r.putChild(b"afterFoundGetCounter", self.afterFoundGetCounter) r.putChild(b"afterFoundGetRedirect", Redirect(b"/afterFoundGetCounter")) miscasedHead = Data(b"miscased-head GET response content", b"major/minor") miscasedHead.render_Head = lambda request: b"miscased-head content" r.putChild(b"miscased-head", miscasedHead) self.extendedRedirect = ExtendedRedirect(b"/extendedRedirect") r.putChild(b"extendedRedirect", self.extendedRedirect) self.site = server.Site(r, timeout=None) self.wrapper = WrappingFactory(self.site) self.port = self._listen(self.wrapper) self.portno = self.port.getHost().port
def setUp(self): root = Data(b"El toro!", b"text/plain") root.putChild(b"cookiemirror", CookieMirrorResource()) root.putChild(b"rawcookiemirror", RawCookieMirrorResource()) site = server.Site(root, timeout=None) self.port = self._listen(site) self.portno = self.port.getHost().port
def setUp(self): self.agent = None # for twisted.web.client.Agent test self.cleanupServerConnections = 0 r = resource.Resource() r.putChild(b"file", Data(b"0123456789", b"text/html")) r.putChild(b"redirect", Redirect(b"/file")) self.infiniteRedirectResource = CountingRedirect(b"/infiniteRedirect") r.putChild(b"infiniteRedirect", self.infiniteRedirectResource) r.putChild(b"wait", ForeverTakingResource()) r.putChild(b"write-then-wait", ForeverTakingResource(write=True)) r.putChild(b"error", ErrorResource()) r.putChild(b"nolength", NoLengthResource()) r.putChild(b"host", HostHeaderResource()) r.putChild(b"payload", PayloadResource()) r.putChild(b"broken", BrokenDownloadResource()) r.putChild(b"cookiemirror", CookieMirrorResource()) r.putChild(b'delay1', DelayResource(1)) r.putChild(b'delay2', DelayResource(2)) self.afterFoundGetCounter = CountingResource() r.putChild(b"afterFoundGetCounter", self.afterFoundGetCounter) r.putChild(b"afterFoundGetRedirect", Redirect(b"/afterFoundGetCounter")) miscasedHead = Data(b"miscased-head GET response content", b"major/minor") miscasedHead.render_Head = lambda request: b"miscased-head content" r.putChild(b"miscased-head", miscasedHead) self.extendedRedirect = ExtendedRedirect(b'/extendedRedirect') r.putChild(b"extendedRedirect", self.extendedRedirect) self.site = server.Site(r, timeout=None) self.wrapper = WrappingFactory(self.site) self.port = self._listen(self.wrapper) self.portno = self.port.getHost().port
def setUp(self): plainRoot = Data(b'not me', b'text/plain') tlsRoot = Data(b'me neither', b'text/plain') plainSite = server.Site(plainRoot, timeout=None) tlsSite = server.Site(tlsRoot, timeout=None) self.tlsPort = reactor.listenSSL( 0, tlsSite, contextFactory=ssl.DefaultOpenSSLContextFactory( serverPEMPath, serverPEMPath), interface="127.0.0.1") self.plainPort = reactor.listenTCP(0, plainSite, interface="127.0.0.1") self.plainPortno = self.plainPort.getHost().port self.tlsPortno = self.tlsPort.getHost().port plainRoot.putChild(b'one', Redirect(self.getHTTPS('two'))) tlsRoot.putChild(b'two', Redirect(self.getHTTP('three'))) plainRoot.putChild(b'three', Redirect(self.getHTTPS('four'))) tlsRoot.putChild(b'four', Data(b'FOUND IT!', b'text/plain'))
def setUp(self): root = Data(b'El toro!', b'text/plain') root.putChild(b"cookiemirror", CookieMirrorResource()) root.putChild(b"rawcookiemirror", RawCookieMirrorResource()) site = server.Site(root, timeout=None) self.port = self._listen(site) self.portno = self.port.getHost().port
def setUp(self): plainRoot = Data(b"not me", b"text/plain") tlsRoot = Data(b"me neither", b"text/plain") plainSite = server.Site(plainRoot, timeout=None) tlsSite = server.Site(tlsRoot, timeout=None) self.tlsPort = reactor.listenSSL( 0, tlsSite, contextFactory=ssl.DefaultOpenSSLContextFactory(serverPEMPath, serverPEMPath), interface="127.0.0.1", ) self.plainPort = reactor.listenTCP(0, plainSite, interface="127.0.0.1") self.plainPortno = self.plainPort.getHost().port self.tlsPortno = self.tlsPort.getHost().port plainRoot.putChild(b"one", Redirect(self.getHTTPS("two"))) tlsRoot.putChild(b"two", Redirect(self.getHTTP("three"))) plainRoot.putChild(b"three", Redirect(self.getHTTPS("four"))) tlsRoot.putChild(b"four", Data(b"FOUND IT!", b"text/plain"))