import json

from xweb.descriptors import HeaderDict
from xweb.status_code import status_code


class Response:
    """
    I have no words to describe this class
    """

    def __init__(self):
        self.body = None
        self.headers = HeaderDict()
        self.status = 200

    def __repr__(self):
        return '<Response {}>'.format(self.status)

    def get_status_detail(self):
        return status_code.get(str(self.status))

    def get_status(self):
        return str(self.status) + ' ' + status_code.get(str(self.status))

    def get_header(self):
        return [(key, val) for key, val in self.headers.items()]

    def get_body(self):
        if self.body is None:
            self.headers['Content-Length'] = 0
            return ''
        if isinstance(self.body, int):
            self.headers['Content-Type'] = 'text/plain'
            return str(self.body)
        if isinstance(self.body, str):
            self.headers['Content-Type'] = 'text/plain'
            return self.body
        if isinstance(self.body, dict):
            self.headers['Content-Type'] = 'text/json'
            return json.dumps(self.body)
        if isinstance(self.body, bytes):
            self.headers['Content-Type'] = 'application/octet-stream'
            return self.body
        return str(self.body)

import json

from xweb.descriptors import HeaderDict
from xweb.status_code import status_code


class Response:
    """
    I have no words to describe this class
    """

    def __init__(self):
        self.body = None
        self.headers = HeaderDict()
        self.status = 200

    def __repr__(self):
        return '<Response {}>'.format(self.status)

    def get_status_detail(self):
        return status_code.get(str(self.status))

    def get_status(self):
        return str(self.status) + ' ' + self.get_status_detail()

    def get_header(self):
        return [(key, val) for key, val in self.headers.items()]

    def get_body(self):
        if self.body is None:
            self.headers['Content-Length'] = 0
            return ''
        if isinstance(self.body, int):
            self.headers['Content-Type'] = 'text/plain'
            return str(self.body)
        if isinstance(self.body, str):
            self.headers['Content-Type'] = 'text/plain'
            return self.body
        if isinstance(self.body, dict):
            self.headers['Content-Type'] = 'text/json'
            return json.dumps(self.body)
        if isinstance(self.body, bytes):
            self.headers['Content-Type'] = 'application/octet-stream'
            return self.body
        return str(self.body)

Update respose.get_status