Exemple #1
0
 def test_non_default_port(self):
     environ = {
         "SERVER_NAME": "localhost",
         "SERVER_PORT": "8080",
         "wsgi.url_scheme": "http",
     }
     self.assertEqual(
         wsgi.Request(environ).url,
         URL(scheme=u"http", host=u"localhost", port=8080),
     )
Exemple #2
0
 def test_no_host_no_path_no_query_string(self):
     environ = {
         "SERVER_NAME": "localhost",
         "SERVER_PORT": "80",
         "wsgi.url_scheme": "http",
     }
     self.assertEqual(
         wsgi.Request(environ).url,
         URL(scheme=u"http", host=u"localhost"),
     )
Exemple #3
0
 def test_host_no_path_no_query_string(self):
     environ = {
         "HTTP_HOST": "example.com",
         "SERVER_NAME": "localhost",
         "SERVER_PORT": "80",
         "wsgi.url_scheme": "http",
     }
     self.assertEqual(
         wsgi.Request(environ).url,
         URL(scheme=b"http", host=b"example.com"),
     )
Exemple #4
0
 def test_script_name(self):
     environ = {
         "HTTP_HOST": "example.org",
         "SCRIPT_NAME": "/stuff",
         "PATH_INFO": "/things",
         "SERVER_PORT": "443",
         "wsgi.url_scheme": "https",
     }
     self.assertEqual(
         wsgi.Request(environ).url,
         URL(scheme=b"https", host=b"example.org", path=b"/stuff/things"),
     )
Exemple #5
0
 def test_query_string(self):
     environ = {
         "SERVER_NAME": "example.com",
         "SERVER_PORT": "80",
         "QUERY_STRING": "foo=bar",
         "wsgi.url_scheme": "http",
     }
     self.assertEqual(
         wsgi.Request(environ).url, URL(
             scheme=u"http",
             host=u"example.com",
             query=[(u"foo", u"bar")],
         ),
     )
Exemple #6
0
 def test_no_http_host_present(self):
     environ = {
         "SERVER_NAME": "example.org",
         "SERVER_PORT": "1234",
         "PATH_INFO": "/",
         "wsgi.url_scheme": "https",
     }
     self.assertEqual(
         wsgi.Request(environ).url, URL(
             scheme=u"https",
             host=u"example.org",
             path=[u""],
             port=1234,
         ),
     )
Exemple #7
0
 def test_http_host_present_default_port(self):
     environ = {
         "HTTP_HOST": "example.org:80",
         "SERVER_PORT": "80",
         "PATH_INFO": "/",
         "wsgi.url_scheme": "https",
     }
     self.assertEqual(
         wsgi.Request(environ).url, URL(
             scheme=u"https",
             host=u"example.org",
             path=[u""],
             port=80,
         ),
     )
Exemple #8
0
 def make_request(self, headers):
     headers = {k: b",".join(v) for k, v in headers.canonicalized()}
     return wsgi.Request(environ=create_environ(headers=headers))