예제 #1
0
    def test_cross_host_redirect(self):
        http = PoolManager()

        cross_host_location = '%s/echo?a=b' % self.base_url_alt
        try:
            yield From(
                http.request('GET',
                             '%s/redirect' % self.base_url,
                             fields={'target': cross_host_location},
                             timeout=0.1,
                             retries=0))
            self.fail(
                "Request succeeded instead of raising an exception like it should."
            )

        except MaxRetryError:
            pass

        r = yield From(
            http.request('GET',
                         '%s/redirect' % self.base_url,
                         fields={'target': '%s/echo?a=b' % self.base_url_alt},
                         timeout=0.1,
                         retries=1))

        self.assertEqual(r._pool.host, self.host_alt)
예제 #2
0
    def test_redirect_to_relative_url(self):
        http = PoolManager()

        r = yield From(
            http.request('GET',
                         '%s/redirect' % self.base_url,
                         fields={'target': '/redirect'},
                         redirect=False))

        self.assertEqual(r.status, 303)

        r = yield From(
            http.request('GET',
                         '%s/redirect' % self.base_url,
                         fields={'target': '/redirect'}))

        self.assertEqual(r.status, 200)
        self.assertEqual((yield From(r.data)), b'Dummy server!')
예제 #3
0
    def test_missing_port(self):
        # Can a URL that lacks an explicit port like ':80' succeed, or
        # will all such URLs fail with an error?

        http = PoolManager()

        # By globally adjusting `port_by_scheme` we pretend for a moment
        # that HTTP's default port is not 80, but is the port at which
        # our test server happens to be listening.
        port_by_scheme['http'] = self.port
        try:
            r = yield From(
                http.request('GET', 'http://%s/' % self.host, retries=0))
        finally:
            port_by_scheme['http'] = 80

        self.assertEqual(r.status, 200)
        self.assertEqual((yield From(r.data)), b'Dummy server!')
예제 #4
0
 def test_ipv6(self):
     http = PoolManager()
     yield From(http.request('GET', self.base_url))
예제 #5
0
    def test_http_with_ssl_keywords(self):
        http = PoolManager(ca_certs='REQUIRED')

        r = yield From(
            http.request('GET', 'http://%s:%s/' % (self.host, self.port)))
        self.assertEqual(r.status, 200)