def handleRequest(self):
        verbose = self._server._verbose
        self._startTime = time.time()
        if verbose:
            print '%5i  %s ' % (self._requestID, timestamp()['pretty']),

        data = []
        dict = self.receiveDict()
        if dict and verbose and dict.has_key('environ'):
            requestURI = Funcs.requestURI(dict['environ'])
            print requestURI
        else:
            requestURI = None

        dict['input'] = self.makeInput()
        streamOut = TASASStreamOut(self._sock)
        transaction = self._server._app.dispatchRawRequest(dict, streamOut)
        streamOut.close()

        try:
            self._sock.shutdown(1)
            self._sock.close()
        except:
            pass

        if self._server._verbose:
            duration = '%0.2f secs' % (time.time() - self._startTime)
            duration = string.ljust(duration, 19)
            print '%5i  %s  %s' % (self._requestID, duration, requestURI)
            print

        transaction._application = None
        transaction.die()
        del transaction
    def handleRequest(self):

        verbose = self.server._verbose

        startTime = time.time()
        if verbose:
            print '%5i  %s ' % (self._number, timestamp()['pretty']),

        conn = self.sock

        # @@ 2001-05-30 ce: Ack! Look at this hard coding.
        BUFSIZE = 8 * 1024

        data = []

        chunk = ''
        missing = int_length
        while missing > 0:
            block = conn.recv(missing)
            if not block:
                conn.close()
                if len(chunk) == 0:
                    # We probably awakened due to awakeSelect being called.
                    return 0
                else:
                    # We got a partial request -- something went wrong.
                    raise NotEnoughDataError, 'received only %d out of %d bytes when receiving dict_length' % (
                        len(chunk), int_length)
            chunk = chunk + block
            missing = int_length - len(chunk)
        dict_length = loads(chunk)
        if type(dict_length) != type(1):
            conn.close()
            print
            print "Error: Invalid AppServer protocol"
            return 0

        chunk = ''
        missing = dict_length
        while missing > 0:
            block = conn.recv(missing)
            if not block:
                conn.close()
                raise NotEnoughDataError, 'received only %d out of %d bytes when receiving dict' % (
                    len(chunk), dict_length)
            chunk = chunk + block
            missing = dict_length - len(chunk)

        dict = loads(chunk)
        #if verbose: print "Comm Delay=%s" % (time.time() - dict['time'])

        if dict:
            if verbose:
                if dict.has_key('environ'):
                    requestURI = Funcs.requestURI(dict['environ'])
                else:
                    requestURI = None
                print requestURI

        dict['input'] = conn.makefile("rb", 8012)

        strmOut = TASASStreamOut(self.sock)
        transaction = self.server._app.dispatchRawRequest(dict, strmOut)
        strmOut.close()

        try:
            conn.shutdown(1)
            conn.close()
        except:
            pass

        if verbose:
            duration = '%0.2f secs' % (time.time() - startTime)
            duration = string.ljust(duration, 19)
            print '%5i  %s  %s' % (self._number, duration, requestURI)
            print

        transaction._application = None
        transaction.die()
        del transaction