def handle_headers(self, data): """ Handler header and return missing data """ #Response Header if data.startswith('-----BEGIN XMLRESPONSE'): try: out = XMLResponseRegex.match(data) if out: self.current_id = int(out.group('id')) self.current_size = int(out.group('size')) self.current_type = XMLRESPONSE_TYPE self.current_size_remaining = self.current_size self.current_data = [] data = out.group('data') else: data = "" except: traceback.print_exc() data = "" return data #Response End elif (self.current_type == XMLRESPONSE_TYPE and data.startswith(END_XMLRESPONSE_HEADER)): self.check_and_alert_size_remaining() outdata = ''.join(self.current_data) self.current_type = None self.current_data = [] id = self.current_id try: response = xmlpickler_loads(outdata)[0][0] if self.open_responses.has_key(id): self.open_responses[id].set_value(response) self.open_responses.pop(id) except Exception, error: self.logger.error(error) traceback.print_exc() data = data[len(END_XMLRESPONSE_HEADER):] return data
data = "" return data #End Request elif (self.current_type == XMLREQUEST_TYPE and data.startswith(END_XMLREQUEST_HEADER)): self.check_and_alert_size_remaining() outdata = ''.join(self.current_data) self.current_type = None self.current_data = [] id = self.current_id params, method = xmlpickler_loads(outdata) if self.server.dispatch_func: response = self.server.dispatch_func(self.hash_id, method, params) else: response = None self.send_response(id, response) data = data[len(END_XMLREQUEST_HEADER):] return data def handle_data(self, data, client_address): """
def handle_headers(self, data): """ Handler header and return missing data """ #Begin XMLRESPONSE if data.startswith('-----BEGIN XMLRESPONSE'): try: out = XMLResponseRegex.match(data) if out: self.current_id = int(out.group('id')) self.current_size = int(out.group('size')) self.current_type = XMLRESPONSE_TYPE self.current_size_remaining = self.current_size self.current_data = [] data = out.group('data') else: data = "" except: traceback.print_exc() data = "" return data #End XMLRESPONSE elif (self.current_type == XMLRESPONSE_TYPE and data.startswith(END_XMLRESPONSE_HEADER)): self.check_and_alert_size_remaining() outdata = ''.join(self.current_data) self.current_type = None self.current_data = [] response = xmlpickler_loads(outdata)[0][0] if self.open_responses.has_key(self.current_id): self.open_responses[self.current_id].set_value(response) self.open_responses.pop(self.current_id) data = data[len(END_XMLRESPONSE_HEADER):] return data #Begin XMLREQUEST elif data.startswith('-----BEGIN XMLREQUEST'): try: out = XMLRequestRegex.match(data) if out: self.current_id = int(out.group('id')) self.current_size = int(out.group('size')) self.current_type = XMLREQUEST_TYPE self.current_size_remaining = self.current_size self.current_data = [] data = out.group('data') else: data = "" except: traceback.print_exc() data = "" return data #End XMLREQUEST elif (self.current_type == XMLREQUEST_TYPE and data.startswith(END_XMLREQUEST_HEADER)): self.check_and_alert_size_remaining() outdata = ''.join(self.current_data) self.current_type = None self.current_data = [] id = self.current_id params, method = xmlpickler_loads(outdata) if self.dispatch_func: response = self.dispatch_func(method, params) else: response = None self.send_response(id, response) data = data[len(END_XMLREQUEST_HEADER):] return data