예제 #1
0
    def run_client_loop(self):
        ""
        res = select.select([self.client_socket.fileno()], [], [], 0.0)
        if res[0]:
            try:
                socket_data = self.client_socket.recv(4096)
            except:
                socket_data = ""
                self.logger.log("*** Exception in client recv() happend.\n")

            if not socket_data:
                self.client_socket_closed = 1
                self.logger.log("*** Client closed connection.\n")

        else:
            socket_data = ""

        if socket_data:
            self.logger_bin_client.log(socket_data)

        self.client_buffer = self.client_buffer + socket_data

        if not self.client_head_obj and not self.tunnel_mode:
            self.client_head_obj, rest = http_header.extract_client_header(self.client_buffer)

            if self.client_head_obj:
                self.logger.log("*** Got client request header.\n")
                self.client_buffer = rest
                self.logger.log("*** Client header:\n=====\n" + self.client_head_obj.__repr__())
                self.guess_client_data_length()

                # mask real values and do transforms
                self.fix_client_header()

        self.check_client_data_length()
예제 #2
0
    def run_client_loop(self):
        ""
        try:
            res = select.select([self.client_socket.fileno()], [], [], 0.0)
        except (socket.error, select.error, ValueError) as e:
            LOG.exception(e)
            thread.exit()
        if res[0]:
            try:
                socket_data = self.client_socket.recv(4096)
            except Exception as e:
                LOG.exception(e)
                socket_data = ""
                self.logger.log("*** Exception in client recv() happend.\n")

            if not socket_data:
                self.client_socket_closed = 1
                self.logger.log("*** Client closed connection.\n")

        else:
            socket_data = ""

        if socket_data:
            LOG.info("client socket_data: \n%s", socket_data)
            self.logger_bin_client.log(socket_data)

        self.client_buffer = self.client_buffer + socket_data

        if not self.client_head_obj and not self.tunnel_mode:
            self.client_head_obj, rest = http_header.extract_client_header(
                self.client_buffer)

            if self.client_head_obj:
                self.logger.log("*** Got client request header.\n")
                self.client_buffer = rest
                self.logger.log("*** Client header:\n=====\n" +
                                self.client_head_obj.__repr__())
                self.guess_client_data_length()

                # mask real values and do transforms
                self.fix_client_header()

        self.check_client_data_length()
예제 #3
0
    def run_client_loop(self):
        try:
            res = select.select([self.client_socket.fileno()], [], [], 0.0)
        except (socket.error, select.error, ValueError):
            thread.exit()
        if res[0]:
            try:
                socket_data = self.client_socket.recv(4096)
            except:
                socket_data = ''
                self.logger.log('*** Exception in client recv() happend.\n')

            if not socket_data:
                self.client_socket_closed = 1
                self.logger.log('*** Client closed connection.\n')

        else:
            socket_data = ''

        if socket_data:
            self.logger_bin_client.log(socket_data)

        self.client_buffer = self.client_buffer + socket_data

        if not self.client_head_obj and not self.tunnel_mode:
            self.client_head_obj, rest = http_header.extract_client_header(
                self.client_buffer)

            if self.client_head_obj:
                self.logger.log("*** Got client request header.\n")
                self.client_buffer = rest
                if self.mode_undecided:
                    self.determine_mode()
                    self.mode_undecided = 0
                self.logger.log('*** Client header:\n=====\n' +
                                self.client_head_obj.__repr__())
                self.guess_client_data_length()

                # mask real values and do transforms
                self.fix_client_header()

        self.check_client_data_length()