def _testRedirectDefault(self, code):
        """
        When getting a redirect, L{client.RedirectAgent} follows the URL
        specified in the L{Location} header field and make a new request.

        @param code: HTTP status code.
        """
        self.agent.request(b'GET', b'http://example.com/foo')

        host, port = self.reactor.tcpClients.pop()[:2]
        self.assertEqual(EXAMPLE_COM_IP, host)
        self.assertEqual(80, port)

        req, res = self.protocol.requests.pop()

        # If possible (i.e.: SSL support is present), run the test with a
        # cross-scheme redirect to verify that the scheme is honored; if not,
        # let's just make sure it works at all.
        if ssl is None:
            scheme = b'http'
            expectedPort = 80
        else:
            scheme = b'https'
            expectedPort = 443

        headers = http_headers.Headers(
            {b'location': [scheme + b'://example.com/bar']})
        response = Response((b'HTTP', 1, 1), code, b'OK', headers, None)
        res.callback(response)

        req2, res2 = self.protocol.requests.pop()
        self.assertEqual(b'GET', req2.method)
        self.assertEqual(b'/bar', req2.uri)

        host, port = self.reactor.tcpClients.pop()[:2]
        self.assertEqual(EXAMPLE_COM_IP, host)
        self.assertEqual(expectedPort, port)

        When getting a redirect, L{client.RedirectAgent} follows the URL
        specified in the L{Location} header field and make a new request.

        @param code: HTTP status code.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_agent.py