'Read each request and respond appropriately.'

def communicate(self):

    request_seen = False
    try:
        while True:
            req = None
            req = self.RequestHandlerClass(self.server, self)
            req.parse_request()
            if self.server.stats['Enabled']:
                self.requests_seen += 1
            if (not req.ready):
                return
            request_seen = True
            req.respond()
            if req.close_connection:
                return
    except socket.error:
        e = sys.exc_info()[1]
        errnum = e.args[0]
        if ((errnum == 'timed    out') or (errnum == 'The    read    operation    timed    out')):
            if ((not request_seen) or (req and req.started_request)):
                if (req and (not req.sent_headers)):
                    try:
                        req.simple_response('408    Request    Timeout')
                    except FatalSSLAlert:
                        return
        elif (errnum not in socket_errors_to_ignore):
            self.server.error_log(('socket.error    %s' % repr(errnum)), level=logging.WARNING, traceback=True)
            if (req and (not req.sent_headers)):
                try:
                    req.simple_response('500    Internal    Server    Error')
                except FatalSSLAlert:
                    return
        return
    except (KeyboardInterrupt, SystemExit):
        raise
    except FatalSSLAlert:
        return
    except NoSSLError:
        if (req and (not req.sent_headers)):
            self.wfile = CP_fileobject(self.socket._sock, 'wb', self.wbufsize)
            req.simple_response('400    Bad    Request', 'The    client    sent    a    plain    HTTP    request,    but    this    server    only    speaks    HTTPS    on    this    port.')
            self.linger = True
    except Exception:
        e = sys.exc_info()[1]
        self.server.error_log(repr(e), level=logging.ERROR, traceback=True)
        if (req and (not req.sent_headers)):
            try:
                req.simple_response('500    Internal    Server    Error')
            except FatalSSLAlert:
                return
