Esempio n. 1
0
 def as_http_request_context(self):
     scheme, domain_or_ip, port, path, _ = urlsplit(self.url)
     host = scheme + "://" + domain_or_ip
     if port:
         host += ":" + str(port)
     body_params, renderer = self.post_data
     return HttpRequestContext(
         host=host, method=self.method, url_path=path, query_params=self.query_string, headers=self.headers,
         renderer=renderer, body_params=body_params
     )
Esempio n. 2
0
 def test_urlsplit_with_non_http_schema(self):
     scheme, host, port = urlsplit("ftp://myhost.com")
     self.assertEqual(scheme, 'ftp')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '')
Esempio n. 3
0
 def test_urlsplit_without_end_slash(self):
     scheme, host, port = urlsplit("myhost.com")
     self.assertEqual(scheme, None)
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '')
Esempio n. 4
0
 def test_urlsplit_https_and_port(self):
     scheme, host, port = urlsplit("https://myhost.com:66/")
     self.assertEqual(scheme, 'https')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '66')
Esempio n. 5
0
 def test_urlsplit_https_schema(self):
     scheme, host, port = urlsplit("https://myhost.com/")
     self.assertEqual(scheme, 'https')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '')
Esempio n. 6
0
 def test_urlsplit_empty_schema(self):
     scheme, host, port = urlsplit("://myhost.com/")
     self.assertEqual(scheme, '')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '')
Esempio n. 7
0
 def test_urlsplit_localhost(self):
     scheme, host, port = urlsplit("http://localhost:8080")
     self.assertEqual(scheme, 'http')
     self.assertEqual(host, 'localhost')
     self.assertEqual(port, '8080')
Esempio n. 8
0
 def test_urlsplit_without_end_slash(self):
     scheme, host, port, _, _ = urlsplit("myhost.com")
     self.assertEqual(scheme, None)
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '')
Esempio n. 9
0
 def test_urlsplit_https_and_port(self):
     scheme, host, port, _, _ = urlsplit("https://myhost.com:66/")
     self.assertEqual(scheme, 'https')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '66')
Esempio n. 10
0
 def test_urlsplit_https_schema(self):
     scheme, host, port, _, _ = urlsplit("https://myhost.com/")
     self.assertEqual(scheme, 'https')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '')
Esempio n. 11
0
 def test_urlsplit_empty_schema(self):
     scheme, host, port, _, _ = urlsplit("://myhost.com/")
     self.assertEqual(scheme, '')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '')
Esempio n. 12
0
 def test_urlsplit_localhost(self):
     scheme, host, port, _, _ = urlsplit("http://localhost:8080")
     self.assertEqual(scheme, 'http')
     self.assertEqual(host, 'localhost')
     self.assertEqual(port, '8080')
Esempio n. 13
0
 def test_urlsplit_with_non_http_schema(self):
     scheme, host, port, _, _ = urlsplit("ftp://myhost.com")
     self.assertEqual(scheme, 'ftp')
     self.assertEqual(host, 'myhost.com')
     self.assertEqual(port, '')