'Write a simple response back to the client.'

def simple_response(self, status, msg=''):

    status = str(status)
    buf = [(((self.server.protocol + SPACE) + status) + CRLF), ('Content-Length:    %s\r\n' % len(msg)), 'Content-Type:    text/plain\r\n']
    if (status[:3] in ('413', '414')):
        self.close_connection = True
        if (self.response_protocol == 'HTTP/1.1'):
            buf.append('Connection:    close\r\n')
        else:
            status = '400    Bad    Request'
    buf.append(CRLF)
    if msg:
        if isinstance(msg, unicodestr):
            msg = msg.encode('ISO-8859-1')
        buf.append(msg)
    try:
        self.conn.wfile.sendall(''.join(buf))
    except socket.error:
        x = sys.exc_info()[1]
        if (x.args[0] not in socket_errors_to_ignore):
            raise
