Example #1
0
 def do_not_encode_cgi_arguments(self) -> None:
     self.environment["SERVER_NAME"] = "www.example.com"
     request = Request(self.environment)
     temporary_redirect(request, self.start_response,
                        "foo?bar=baz&abc=%6A;+,@:$")
     self.start_response.assert_header_equals(
         "Location", "http://www.example.com/foo?bar=baz&abc=%6A;+,@:$")
Example #2
0
 def extra_headers(self) -> None:
     request = Request(self.environment)
     temporary_redirect(
         request,
         self.start_response,
         "foo",
         extra_headers=[("X-Foo", "Bar")],
     )
     self.start_response.assert_header_equals("X-Foo", "Bar")
Example #3
0
 def headers(self) -> None:
     self.environment["SERVER_NAME"] = "www.example.com"
     request = Request(self.environment)
     temporary_redirect(request, self.start_response, "/foo/bar")
     self.start_response.assert_status(HTTPStatus.TEMPORARY_REDIRECT)
     self.start_response.assert_header_equals("Content-Type",
                                              "text/html; charset=utf-8")
     self.start_response.assert_header_equals(
         "Location", "http://www.example.com/foo/bar")
Example #4
0
 def html(self) -> None:
     request = Request(self.environment)
     response = temporary_redirect(request, self.start_response, "foo/bar")
     html = b"".join(response).decode("utf-8")
     assert html.startswith("<!DOCTYPE html>")
     assert_in("http://www.example.com/foo/bar", html)
Example #5
0
 def umlauts_in_url(self) -> None:
     self.environment["SERVER_NAME"] = "www.example.com"
     request = Request(self.environment)
     temporary_redirect(request, self.start_response, "foo/bär")
     self.start_response.assert_header_equals(
         "Location", "http://www.example.com/foo/b%C3%A4r")
Example #6
0
 def url_without_leading_slash(self) -> None:
     self.environment["SERVER_NAME"] = "www.example.com"
     request = Request(self.environment)
     temporary_redirect(request, self.start_response, "foo/bar")
     self.start_response.assert_header_equals(
         "Location", "http://www.example.com/foo/bar")
Example #7
0
 def absolute_url(self) -> None:
     request = Request(self.environment)
     temporary_redirect(request, self.start_response,
                        "http://example.com/foo")
     self.start_response.assert_header_equals("Location",
                                              "http://example.com/foo")
Example #8
0
 def temporary_redirect(self, url_part: str) -> Iterable[bytes]:
     return temporary_redirect(self.request, self.start_response, url_part)