/* * Transfer entity headers of a body part (it is, from the content entity) * to a header list. Push Message, chapter 6.2.1.10 states that Content-Type * header is mandatory. * Message proper starts after first empty line. We search only to it, and * remove the line here. * Return 0 when error, 1 otherwise. In addition, return the modified body * part and content headers. */ static int pass_data_headers(Octstr **body_part, List **data_headers) { *data_headers = http_create_empty_headers(); if (check_data_content_type_header(body_part, data_headers, octstr_imm("\r\n\r\n")) == 0) { warning(0, "MIME: pass_data_headers: Content-Type header missing"); return 0; } if (pass_optional_header(body_part, "Content-Transfer-Encoding", data_headers, octstr_imm("\r\n\r\n")) < 0) goto operror; if (pass_optional_header(body_part, "Content-ID", data_headers, octstr_imm("\r\n\r\n")) < 0) goto operror; if (pass_optional_header(body_part, "Content-Description", data_headers, octstr_imm("\r\n\r\n")) < 0) goto operror; if (pass_extension_headers(body_part, data_headers, octstr_imm("\r\n\r\n")) == 0) goto operror; octstr_delete(*body_part, 0, octstr_len(octstr_imm("\r\n"))); return 1; operror: warning(0, "MIME: pass_data_headers: an unparsable optional header"); return 0; }
/* * Transfer entity headers of a body part (it is, from the content entity) * to a header list. Push Message, chapter 6.2.1.10 states that Content-Type * header is mandatory. * Message proper starts after first empty line. We search only to it, and * remove the line here. * Return 0 when error, 1 otherwise. In addition, return the modified body * part and content headers. */ static int pass_data_headers(Octstr **body_part, List **data_headers) { *data_headers = http_create_empty_headers(); /* Transform X-WAP-Application headers as per PPG 6.1.2.1. * Note that missing header means that wml.ua is assumed. */ if (check_data_x_wap_application_id_header(body_part, data_headers, octstr_imm("\r\n\r\n")) == 0) { warning(0, "MIME: %s: X-Wap-Application-Id header missing, assuming 'wml.ua'", __func__); gwlist_append(*data_headers, octstr_create("X-Wap-Application-Id: wml.ua")); } if (check_data_content_type_header(body_part, data_headers, octstr_imm("\r\n\r\n")) == 0) { warning(0, "MIME: %s: Content-Type header missing", __func__); return 0; } if (pass_optional_header(body_part, "Content-Transfer-Encoding", data_headers, octstr_imm("\r\n\r\n")) < 0) goto operror; if (pass_optional_header(body_part, "Content-ID", data_headers, octstr_imm("\r\n\r\n")) < 0) goto operror; if (pass_optional_header(body_part, "Content-Description", data_headers, octstr_imm("\r\n\r\n")) < 0) goto operror; if (pass_extension_headers(body_part, data_headers, octstr_imm("\r\n\r\n")) == 0) goto operror; /* * XXX: TODO: This assumes that there are no further headers prefixing * the MIME body. Which MAY not be the case. We SHOULD rather move all * headers to the data_headers and ensure by this that there are no * left overs. */ octstr_delete(*body_part, 0, octstr_len(octstr_imm("\r\n"))); return 1; operror: warning(0, "MIME: pass_data_headers: an unparseable optional header"); return 0; }