def test_redirection_relative_url(self):
        # Given an HTTP response with a redirection to a relative URL
        http_response = _MockHttpResponse(status=302, _headers={"Location": "/newpath"},)

        # When it gets parsed
        next_location_path = _detect_http_redirection(
            http_response=http_response, server_host_name="lol.com", server_port=443
        )

        # The new location is returned
        assert next_location_path == "/newpath"
    def test_redirection_absolute_url_different_port(self):
        # Given an HTTP response with a redirection to an absolute URL that points to a different port
        http_response = _MockHttpResponse(status=302, _headers={"Location": "https://lol.com:444/newpath"},)

        # When it gets parsed
        next_location_path = _detect_http_redirection(
            http_response=http_response, server_host_name="lol.com", server_port=443
        )

        # No new location is returned
        assert next_location_path is None
    def test_no_redirection(self):
        # Given an HTTP response with no redirection
        http_response = _MockHttpResponse(status=200, _headers={},)

        # When it gets parsed
        next_location_path = _detect_http_redirection(
            http_response=http_response, server_host_name="lol.com", server_port=443
        )

        # No new location is returned
        assert next_location_path is None