Ejemplo n.º 1
0
 def test_mixed_case_scheme_acceptable(self):
     proxies = getproxies()
     s = requests.Session()
     s.proxies = proxies
     r = requests.Request('GET', 'http://httpbin.org/get')
     r = s.send(r.prepare())
     self.assertEqual(r.status_code,200)
     s = requests.Session()
     s.proxies = proxies
     r = requests.Request('GET', 'HTTP://httpbin.org/get')
     r = s.send(r.prepare())
     self.assertEqual(r.status_code,200)
     r = requests.Request('GET', 'hTTp://httpbin.org/get')
     r = s.send(r.prepare())
     self.assertEqual(r.status_code,200)
     r = requests.Request('GET', 'HttP://httpbin.org/get')
     r = s.send(r.prepare())
     self.assertEqual(r.status_code,200)
     r = requests.Request('GET', 'https://httpbin.org/get')
     r = s.send(r.prepare())
     self.assertEqual(r.status_code,200)
     r = requests.Request('GET', 'HTTPS://httpbin.org/get')
     r = s.send(r.prepare())
     self.assertEqual(r.status_code,200)
     r = requests.Request('GET', 'hTTps://httpbin.org/get')
     r = s.send(r.prepare())
     self.assertEqual(r.status_code,200)
     r = requests.Request('GET', 'HttPs://httpbin.org/get')
     r = s.send(r.prepare())
     self.assertEqual(r.status_code,200)
Ejemplo n.º 2
0
    def test_HTTP_200_OK_GET_ALTERNATIVE(self):
        r = requests.Request('GET', httpbin('get'))
        s = requests.Session()
        s.proxies = getproxies()

        r = s.send(r.prepare())

        assert r.status_code == 200
Ejemplo n.º 3
0
    def test_HTTP_200_OK_GET_ALTERNATIVE(self):
        r = requests.Request('GET', httpbin('get'))
        s = requests.Session()
        s.proxies = getproxies()

        r = s.send(r.prepare())

        self.assertEqual(r.status_code, 200)
Ejemplo n.º 4
0
    def test_HTTP_200_OK_GET_ALTERNATIVE(self):
        r = requests.Request("GET", httpbin("get"))
        s = requests.Session()
        s.proxies = getproxies()

        r = s.send(r.prepare())

        assert r.status_code == 200
Ejemplo n.º 5
0
 def test_mixed_case_scheme_acceptable(self, httpbin, scheme):
     s = requests.Session()
     s.proxies = getproxies()
     parts = urlparse(httpbin('get'))
     url = scheme + parts.netloc + parts.path
     r = requests.Request('GET', url)
     r = s.send(r.prepare())
     assert r.status_code == 200, 'failed for scheme {0}'.format(scheme)
Ejemplo n.º 6
0
 def test_mixed_case_scheme_acceptable(self, httpbin, scheme):
     s = requests.Session()
     s.proxies = getproxies()
     parts = urlparse(httpbin('get'))
     url = scheme + parts.netloc + parts.path
     r = requests.Request('GET', url)
     r = s.send(r.prepare())
     assert r.status_code == 200, 'failed for scheme {0}'.format(scheme)
Ejemplo n.º 7
0
    def test_session_pickling(self):
        r = requests.Request('GET', httpbin('get'))
        s = requests.Session()

        s = pickle.loads(pickle.dumps(s))
        s.proxies = getproxies()

        r = s.send(r.prepare())
        self.assertEqual(r.status_code, 200)
Ejemplo n.º 8
0
    def test_session_pickling(self):
        r = requests.Request("GET", httpbin("get"))
        s = requests.Session()

        s = pickle.loads(pickle.dumps(s))
        s.proxies = getproxies()

        r = s.send(r.prepare())
        assert r.status_code == 200
Ejemplo n.º 9
0
    def test_session_pickling(self):
        r = requests.Request('GET', httpbin('get'))
        s = requests.Session()

        s = pickle.loads(pickle.dumps(s))
        s.proxies = getproxies()

        r = s.send(r.prepare())
        assert r.status_code == 200
Ejemplo n.º 10
0
 def test_mixed_case_scheme_acceptable(self):
     s = requests.Session()
     s.proxies = getproxies()
     parts = urlparse(httpbin("get"))
     schemes = ["http://", "HTTP://", "hTTp://", "HttP://", "https://", "HTTPS://", "hTTps://", "HttPs://"]
     for scheme in schemes:
         url = scheme + parts.netloc + parts.path
         r = requests.Request("GET", url)
         r = s.send(r.prepare())
         assert r.status_code == 200, "failed for scheme {0}".format(scheme)
Ejemplo n.º 11
0
 def test_mixed_case_scheme_acceptable(self):
     s = requests.Session()
     s.proxies = getproxies()
     parts = urlparse(httpbin('get'))
     schemes = ['http://', 'HTTP://', 'hTTp://', 'HttP://',
                'https://', 'HTTPS://', 'hTTps://', 'HttPs://']
     for scheme in schemes:
         url = scheme + parts.netloc + parts.path
         r = requests.Request('GET', url)
         r = s.send(r.prepare())
         assert r.status_code == 200, 'failed for scheme {0}'.format(scheme)
Ejemplo n.º 12
0
 def test_mixed_case_scheme_acceptable(self):
     s = requests.Session()
     s.proxies = getproxies()
     parts = urlparse(httpbin('get'))
     schemes = ['http://', 'HTTP://', 'hTTp://', 'HttP://',
                'https://', 'HTTPS://', 'hTTps://', 'HttPs://']
     for scheme in schemes:
         url = scheme + parts.netloc + parts.path
         r = requests.Request('GET', url)
         r = s.send(r.prepare())
         assert r.status_code == 200, 'failed for scheme {0}'.format(scheme)
Ejemplo n.º 13
0
    def test_prepared_request_hook(self):
        def hook(resp, **kwargs):
            resp.hook_working = True
            return resp

        req = requests.Request("GET", HTTPBIN, hooks={"response": hook})
        prep = req.prepare()

        s = requests.Session()
        s.proxies = getproxies()
        resp = s.send(prep)

        assert hasattr(resp, "hook_working")
Ejemplo n.º 14
0
    def test_prepared_request_hook(self):
        def hook(resp, **kwargs):
            resp.hook_working = True
            return resp

        req = requests.Request('GET', HTTPBIN, hooks={'response': hook})
        prep = req.prepare()

        s = requests.Session()
        s.proxies = getproxies()
        resp = s.send(prep)

        assert hasattr(resp, 'hook_working')
Ejemplo n.º 15
0
    def test_prepared_request_hook(self):
        def hook(resp, **kwargs):
            resp.hook_working = True
            return resp

        req = requests.Request('GET', HTTPBIN, hooks={'response': hook})
        prep = req.prepare()

        s = requests.Session()
        s.proxies = getproxies()
        resp = s.send(prep)

        self.assertTrue(hasattr(resp, 'hook_working'))
Ejemplo n.º 16
0
 def _get_client(self, sid, token):
     proxy_client = TwilioHttpClient()
     proxy_client.session.proxies = getproxies()
     return Client(sid, token, http_client=proxy_client)
Ejemplo n.º 17
0
 def _get_client(self, sid, token):
     proxy_client = TwilioHttpClient()
     proxy_client.session.proxies = getproxies()
     return Client(sid, token, http_client=proxy_client)