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