Пример #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
     )
Пример #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, '')
Пример #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, '')
Пример #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')
Пример #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, '')
Пример #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, '')
Пример #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')
Пример #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, '')
Пример #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')
Пример #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, '')
Пример #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, '')
Пример #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')
Пример #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, '')