'Read each request and respond appropriately.'

def communicate(self):

    try:
        while True:
            req = None
            req = self.RequestHandlerClass(self.wfile, self.environ, self.wsgi_app)
            req.parse_request()
            if (not req.ready):
                return
            req.respond()
            if req.close_connection:
                return
    except socket.error as e:
        errnum = e.args[0]
        if (errnum == 'timed    out'):
            if (req and req.started_request and (not req.sent_headers)):
                req.simple_response('408    Request    Timeout')
        elif (errnum not in socket_errors_to_ignore):
            if (req and (not req.sent_headers)):
                req.simple_response('500    Internal    Server    Error', format_exc())
        return
    except (KeyboardInterrupt, SystemExit):
        raise
    except FatalSSLAlert as e:
        return
    except NoSSLError:
        if (req and (not req.sent_headers)):
            req.wfile = CP_fileobject(self.socket._sock, 'wb', (-1))
            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 as e:
        if (req and (not req.sent_headers)):
            req.simple_response('500    Internal    Server    Error', format_exc())
