Пример #1
0
    def host(self, value):
        """
        A string that will be automatically included at the beginning of the url generated for doing each http request.

        :param value: The host to be connected with, e.g. (http://hostname) or (https://X.X.X.X:port)
        """
        scheme, host, port = get_hostname_parameters_from_url(value)
        self._host = "%s://%s:%s" % (scheme, host, port)
Пример #2
0
    def host(self, value):
        """
        A string that will be automatically included at the beginning of the url generated for doing each http request.

        :param value: The host to be connected with, e.g. (http://hostname) or (https://X.X.X.X:port)
        """
        scheme, host, port = get_hostname_parameters_from_url(value)
        self._host = "%s://%s:%s" % (scheme, host, port)
Пример #3
0
    def set_default_host(cls, value):
        """
        Default: "http://127.0.0.1:80"

        A string that will be automatically included at the beginning of the url generated for doing each http request.
        """
        if value is None:
            cls.DEFAULT_HOST = "http://127.0.0.1:80"
        else:
            scheme, host, port = get_hostname_parameters_from_url(value)
            cls.DEFAULT_HOST = "%s://%s:%s" % (scheme, host, port)
Пример #4
0
    def set_default_host(cls, value):
        """
        Default: "http://127.0.0.1:80"

        A string that will be automatically included at the beginning of the url generated for doing each http request.
        """
        if value is None:
            cls.DEFAULT_HOST = "http://127.0.0.1:80"
        else:
            scheme, host, port = get_hostname_parameters_from_url(value)
            cls.DEFAULT_HOST = "%s://%s:%s" % (scheme, host, port)
Пример #5
0
    def set_default_proxy(cls, value):
        """
        Default: None (no proxy)

        A string that will be used to tell each request must be sent through this proxy server.
        Use the scheme://hostname:port form.
        If you need to use a proxy, you can configure individual requests with the proxies argument to any request
        method.
        """
        if value is None:
            cls.DEFAULT_PROXY = None
        else:
            scheme, host, port = get_hostname_parameters_from_url(value)
            cls.DEFAULT_PROXY = "%s://%s:%s" % (scheme, host, port)
Пример #6
0
    def set_default_proxy(cls, value):
        """
        Default: None (no proxy)

        A string that will be used to tell each request must be sent through this proxy server.
        Use the scheme://hostname:port form.
        If you need to use a proxy, you can configure individual requests with the proxies argument to any request
        method.
        """
        if value is None:
            cls.DEFAULT_PROXY = None
        else:
            scheme, host, port = get_hostname_parameters_from_url(value)
            cls.DEFAULT_PROXY = "%s://%s:%s" % (scheme, host, port)
Пример #7
0
 def test_get_hostname_parameters_from_url_with_http_schema(self):
     scheme, host, port = get_hostname_parameters_from_url("http://myhost.com/")
     self.assertEqual(scheme, 'http')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '80')
Пример #8
0
 def test_get_hostname_parameters_from_url_without_end_slash_(self):
     scheme, host, port = get_hostname_parameters_from_url("myhost.com")
     self.assertEqual(scheme, 'http')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '80')
Пример #9
0
 def test_get_hostname_parameters_from_url_http_and_non_default_port(self):
     scheme, host, port = get_hostname_parameters_from_url("http://myhost.com:66/")
     self.assertEqual(scheme, 'http')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '66')
Пример #10
0
 def test_get_hostname_parameters_from_url_with_subdomain(self):
     scheme, host, port = get_hostname_parameters_from_url("https://cybersecurity-telefonica.e-paths.com")
     self.assertEqual(scheme, 'https')
     self.assertEqual(host, 'cybersecurity-telefonica.e-paths.com')
     self.assertEqual(port, '443')
Пример #11
0
 def test_get_hostname_parameters_from_url_with_http_schema(self):
     scheme, host, port, = get_hostname_parameters_from_url(
         "http://myhost.com/")
     self.assertEqual(scheme, 'http')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '80')
Пример #12
0
 def test_get_hostname_parameters_from_url_without_end_slash_(self):
     scheme, host, port = get_hostname_parameters_from_url("myhost.com")
     self.assertEqual(scheme, 'http')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '80')
Пример #13
0
 def test_get_hostname_parameters_from_url_http_and_non_default_port(self):
     scheme, host, port = get_hostname_parameters_from_url(
         "http://myhost.com:66/")
     self.assertEqual(scheme, 'http')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '66')
Пример #14
0
 def test_get_hostname_parameters_from_url_with_subdomain(self):
     scheme, host, port = get_hostname_parameters_from_url(
         "https://cybersecurity-telefonica.e-paths.com")
     self.assertEqual(scheme, 'https')
     self.assertEqual(host, 'cybersecurity-telefonica.e-paths.com')
     self.assertEqual(port, '443')