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)
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)
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)
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)
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)
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)
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')
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')
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')
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')
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')
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')
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')
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')