def process_headers(self): for header, value in self.payload.items(): if header == "Content-Type": expression = CommonMethods.get_content_type(value) if len(expression) == 3: self.content_type = expression[0] self.boundary_string = expression[2] else: self.content_type = expression[0]
def process_headers(self): if isinstance(self.payload, str): self.body_content = self.payload self.body_only = True return for header, value in self.payload.items(): if header == "Content-Type": expression = CommonMethods.get_content_type(value) if len(expression) > 1: self.content_type = expression[0] # Is this a charset identification if expression[1] == 'charset': self.charset = expression[2] else: self.content_type_param.append(Parameter(expression[1], expression[2])) continue else: self.content_type = expression[0] continue if header == "Content-Transfer-Encoding": self.transfer_encoding = value continue if header == "Content-Disposition": try: self.disposition = value.split(";")[0] fn = value.split(";")[1].split("=")[1] if len(fn.split("''")) > 1: self.disposition_file_name = unquote(fn.split("''")[1]) else: self.disposition_file_name = unquote(fn) continue except IndexError as e: self.other_mime_header.append(Header(header, value)) if header == "Content-ID": self.content_id = CommonMethods.cdata_wrap(value) continue if header == "Content-Description": self.content_name = value continue self.other_mime_header.append(Header(header, value))