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
            else:
                if (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"))
            else:
                if 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", rfc822.formatdate()))
        if "server" not in hkeys:
            self.outheaders.append(("Server", self.server.server_name))
        buf = [self.server.protocol + " " + self.status + CRLF]
        for k, v in self.outheaders:
            buf.append(k + ": " + v + CRLF)
        buf.append(CRLF)
        self.conn.wfile.sendall("".join(buf))