"""
Response objects used in satosa
"""


class Response(object):
    """
    A response object
    """
    # _template = None
    _status = '200 OK'
    _content_type = 'text/html'

    def __init__(self, message=None, status=None, headers=None, content=None):
        """
        Creates a Responses
        :type message: str
        :type status: str
        :type headers: list[(str, str)]
        :type content: str

        :param message: The response message
        :param status: The response status code
        :param headers: A list of headers
        :param content: The content type
        """
        _content_type = content if content is not None else self._content_type
        self.status = status if status is not None else self._status
        self.headers = headers if headers is not None else []
        self.message = message

        should_add_content_type = not any(header[0].lower() == 'content-type' for header in self.headers)
        if should_add_content_type:
            self.headers.append(("Content-Type", _content_type))

    def __call__(self, environ, start_response):
        """
        Help method when using a WSGI application server.
        Creates a response from environ and start_response

        :type environ: dict[str, str]
        :type start_response: (str, list[(str, str)]) -> None

        :param environ: The WSGI environ
        :param start_response: The WSGI start_response
        :return:
        """
        start_response(self.status, self.headers)
        return [self.message]


class Redirect(Response):
    """
    A Redirect response
    """
    _status = '302 Found'

    def __init__(self, redirect_url, headers=None, content=None):
        """
        Crete a redirect response

        :type redirect_url: str
        :type headers: list[(str,str)]
        :type content: str

        :param redirect_url: The redirect url
        :param headers: A list of headers
        :param content: Content type
        """
        super().__init__(redirect_url, headers=headers, content=content)
        self.headers.append(("Location", redirect_url))


class SeeOther(Redirect):
    """
    A SeeOther response
    """
    _status = '303 See Other'

    def __init__(self, redirect_url, headers=None, content=None):
        """
        Creates a SeeOther response

        :type redirect_url: str
        :type headers: list[(str, str)]
        :type content: str

        :param redirect_url: The redirect url
        :param headers: A list of headers
        :param content: The content type
        """
        super().__init__(redirect_url, headers=headers, content=content)

@@ -138,16 +138,16 @@
 s = 
-'
+%22
 200 OK
-'
+%22
 %0A   
@@ -163,17 +163,17 @@
 _type = 
-'
+%22
 text/htm
@@ -173,17 +173,17 @@
 ext/html
-'
+%22
 %0A%0A    de
@@ -909,17 +909,17 @@
 er() == 
-'
+%22
 content-
@@ -922,17 +922,17 @@
 ent-type
-'
+%22
  for hea
@@ -1621,17 +1621,17 @@
 tatus = 
-'
+%22
 302 Foun
@@ -1631,17 +1631,17 @@
 02 Found
-'
+%22
 %0A%0A    de
@@ -2194,17 +2194,17 @@
 tatus = 
-'
+%22
 303 See 
@@ -2212,9 +2212,9 @@
 ther
-'
+%22
 %0A%0A  
@@ -2559,32 +2559,32 @@
 ype%0A        %22%22%22%0A
-
         super().
@@ -2620,28 +2620,161 @@
 s=headers, content=content)%0A
+%0A%0Aclass NotFound(Response):%0A    _status = %22404 Not Found%22%0A%0A%0Aclass ServiceError(Response):%0A    _status = %22500 Internal Service Error%22%0A

Add NotFound and ServiceError response classes.