'Assert, process, and send the HTTP response message-headers.
You must set self.status, and self.outheaders before calling this.'

def send_headers(self):

    hkeys = [key.lower() for (key, value) in self.outheaders]
    status = int(self.status[:3])
    if (status == 413):
        self.close_connection = True
    elif ('content-length' not in hkeys):
        if ((status < 200) or (status in (204, 205, 304))):
            pass
        elif ((self.response_protocol == 'HTTP/1.1') and (self.method != 'HEAD')):
            self.chunked_write = True
            self.outheaders.append(('Transfer-Encoding', 'chunked'))
        else:
            self.close_connection = True
    if ('connection' not in hkeys):
        if (self.response_protocol == 'HTTP/1.1'):
            if self.close_connection:
                self.outheaders.append(('Connection', 'close'))
        elif (not self.close_connection):
            self.outheaders.append(('Connection', 'Keep-Alive'))
    if ((not self.close_connection) and (not self.chunked_read)):
        remaining = getattr(self.rfile, 'remaining', 0)
        if (remaining > 0):
            self.rfile.read(remaining)
    if ('date' not in hkeys):
        self.outheaders.append(('Date', email.utils.formatdate()))
    if ('server' not in hkeys):
        self.outheaders.append(('Server', self.server.server_name))
    buf = [(((self.server.protocol + SPACE) + self.status) + CRLF)]
    for (k, v) in self.outheaders:
        buf.append(((((k + COLON) + SPACE) + v) + CRLF))
    buf.append(CRLF)
    self.conn.wfile.sendall(EMPTY.join(buf))
