def handle_read(self): self.rbuff += self.recv(self.in_buffer_size) msg = self.get_block() if msg: request = Request() request.from_string(msg) gevent.spawn(self.render, request).join()
def get_block(self): """ Get http request :return: http request """ block = None if self.is_block_ready(): rindex = Request.get_message_len(self.rbuff) block = self.rbuff[:rindex] self.rbuff = self.rbuff[rindex:] return block
def is_block_ready(self): """ Check reade buffer to completeness :return: read buffer complete - True, else - False """ return Request.is_message_ready(self.rbuff)