예제 #1
0
    def __init__(self, channel, queued, reactor=reactor):

        ReverseProxyRequest.__init__(self, channel, queued, reactor)
        now = datetime.datetime.now()
        self.createdAt = now.strftime('%Y-%m-%d %H:%M:%S')
        self.transaction_id = uuid.uuid1()
        self.request_id = uuid.uuid1()
        self.response_id = uuid.uuid1()

        self.module_registry = channel.site.resource.module_registry
        self.upstream_host = channel.site.resource.host
        self.upstream_port = channel.site.resource.port

        self.drop_connection = False
        self.reset_connection = False
        self.delay = 0
예제 #2
0
    def __init__(self, channel, queued, reactor=reactor):

        ReverseProxyRequest.__init__(self, channel, queued, reactor)
        now = datetime.datetime.now()
        self.createdAt = now.strftime('%Y-%m-%d %H:%M:%S')
        self.transaction_id = uuid.uuid1()
        self.request_id = uuid.uuid1()
        self.response_id = uuid.uuid1()

        self.module_registry = channel.site.resource.module_registry
        self.upstream_host = channel.site.resource.host
        self.upstream_port = channel.site.resource.port

        self.drop_connection = False
        self.reset_connection = False
        self.delay = 0
예제 #3
0
    def test_process(self):
        """
        L{ReverseProxyRequest.process} should create a connection to its
        factory host/port, using a L{ProxyClientFactory} instantiated with the
        correct parameters, and particularly set the B{host} header to the
        factory host.
        """
        transport = StringTransportWithDisconnection()
        channel = DummyChannel(transport)
        reactor = MemoryReactor()
        request = ReverseProxyRequest(channel, False, reactor)
        request.factory = DummyFactory("example.com", 1234)
        request.gotLength(0)
        request.requestReceived(b"GET", b"/foo/bar", b"HTTP/1.0")

        # Check that one connection has been created, to the good host/port
        self.assertEqual(len(reactor.tcpClients), 1)
        self.assertEqual(reactor.tcpClients[0][0], "example.com")
        self.assertEqual(reactor.tcpClients[0][1], 1234)

        # Check the factory passed to the connect, and its headers
        factory = reactor.tcpClients[0][2]
        self.assertIsInstance(factory, ProxyClientFactory)
        self.assertEqual(factory.headers, {b"host": b"example.com"})
예제 #4
0
    def test_process(self):
        """
        L{ReverseProxyRequest.process} should create a connection to its
        factory host/port, using a L{ProxyClientFactory} instantiated with the
        correct parameters, and particulary set the B{host} header to the
        factory host.
        """
        transport = StringTransportWithDisconnection()
        channel = DummyChannel(transport)
        reactor = MemoryReactor()
        request = ReverseProxyRequest(channel, False, reactor)
        request.factory = DummyFactory("example.com", 1234)
        request.gotLength(0)
        request.requestReceived("GET", "/foo/bar", "HTTP/1.0")

        # Check that one connection has been created, to the good host/port
        self.assertEquals(len(reactor.tcpClients), 1)
        self.assertEquals(reactor.tcpClients[0][0], "example.com")
        self.assertEquals(reactor.tcpClients[0][1], 1234)

        # Check the factory passed to the connect, and its headers
        factory = reactor.tcpClients[0][2]
        self.assertIsInstance(factory, ProxyClientFactory)
        self.assertEquals(factory.headers, {"host": "example.com"})