fix for mmsbox multipart sendmms handling
This commit is contained in:
parent
d05d46cc9f
commit
a69feb2eb9
|
@ -205,4 +205,9 @@ void *_mms_load_module(mCfgGrp *grp, char *config_key, char *symbolname,
|
||||||
#define BACKOFF_FACTOR 5*60 /* In seconds */
|
#define BACKOFF_FACTOR 5*60 /* In seconds */
|
||||||
#define QUEUERUN_INTERVAL 1*60 /* 1 minutes. */
|
#define QUEUERUN_INTERVAL 1*60 /* 1 minutes. */
|
||||||
#define DEFAULT_EXPIRE 3600*24*7 /* One week */
|
#define DEFAULT_EXPIRE 3600*24*7 /* One week */
|
||||||
|
|
||||||
|
#define HTTP_REPLACE_HEADER(hdr, hname, value) do { \
|
||||||
|
http_header_remove_all((hdr), (hname)); \
|
||||||
|
http_header_add((hdr), (hname), (value)); \
|
||||||
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -928,7 +928,13 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
||||||
/* Now get the data. */
|
/* Now get the data. */
|
||||||
if (octstr_case_compare(ctype, octstr_imm("application/vnd.wap.mms-message")) == 0)
|
if (octstr_case_compare(ctype, octstr_imm("application/vnd.wap.mms-message")) == 0)
|
||||||
m = mms_frombinary(data, from);
|
m = mms_frombinary(data, from);
|
||||||
else if (octstr_case_compare(ctype, octstr_imm("application/smil")) == 0) {
|
else if (octstr_case_search(ctype, octstr_imm("multipart/"), 0) == 0) { /* treat it differently. */
|
||||||
|
MIMEEntity *mime = mime_http_to_entity(reply_headers, data);
|
||||||
|
if (mime) {
|
||||||
|
m = mms_frommime(mime);
|
||||||
|
mime_entity_destroy(mime);
|
||||||
|
}
|
||||||
|
} else if (octstr_case_compare(ctype, octstr_imm("application/smil")) == 0) {
|
||||||
xmlDocPtr smil;
|
xmlDocPtr smil;
|
||||||
xmlChar *buf = NULL;
|
xmlChar *buf = NULL;
|
||||||
int bsize = 0;
|
int bsize = 0;
|
||||||
|
@ -1186,7 +1192,7 @@ static void sendmms_func(void *unused)
|
||||||
Octstr *rr_url, *allow_adaptations, *subject = NULL;
|
Octstr *rr_url, *allow_adaptations, *subject = NULL;
|
||||||
List *lto = NULL, *rh = http_create_empty_headers();
|
List *lto = NULL, *rh = http_create_empty_headers();
|
||||||
Octstr *rb = NULL, *base_url;
|
Octstr *rb = NULL, *base_url;
|
||||||
int i, n;
|
int i, n, skip_ctype = 0;
|
||||||
Octstr *vasid = http_cgi_variable(cgivars, "vasid");
|
Octstr *vasid = http_cgi_variable(cgivars, "vasid");
|
||||||
Octstr *service_code = http_cgi_variable(cgivars, "servicecode");
|
Octstr *service_code = http_cgi_variable(cgivars, "servicecode");
|
||||||
Octstr *mclass = http_cgi_variable(cgivars, "mclass");
|
Octstr *mclass = http_cgi_variable(cgivars, "mclass");
|
||||||
|
@ -1216,12 +1222,12 @@ static void sendmms_func(void *unused)
|
||||||
} else if ((data = http_cgi_variable(cgivars, "smil")) != NULL) /* smil. */
|
} else if ((data = http_cgi_variable(cgivars, "smil")) != NULL) /* smil. */
|
||||||
ctype = octstr_imm("application/smil");
|
ctype = octstr_imm("application/smil");
|
||||||
else if ((data = http_cgi_variable(cgivars, "content-url")) != NULL) { /* arbitrary content. */
|
else if ((data = http_cgi_variable(cgivars, "content-url")) != NULL) { /* arbitrary content. */
|
||||||
List *rh = http_create_empty_headers(), *rph = NULL;
|
List *reqh = http_create_empty_headers(), *rph = NULL;
|
||||||
Octstr *reply = NULL, *params = NULL;
|
Octstr *reply = NULL, *params = NULL;
|
||||||
|
|
||||||
http_header_add(rh, "User-Agent", MM_NAME "/" VERSION);
|
http_header_add(reqh, "User-Agent", MM_NAME "/" VERSION);
|
||||||
|
|
||||||
if (mmsbox_url_fetch_content(HTTP_METHOD_GET, data, rh, octstr_imm(""), &rph, &reply) == HTTP_OK)
|
if (mmsbox_url_fetch_content(HTTP_METHOD_GET, data, reqh, octstr_imm(""), &rph, &reply) == HTTP_OK)
|
||||||
get_content_type(rph, &ctype, ¶ms);
|
get_content_type(rph, &ctype, ¶ms);
|
||||||
else
|
else
|
||||||
rb = octstr_format("failed to fetch content from url [%S]!", data);
|
rb = octstr_format("failed to fetch content from url [%S]!", data);
|
||||||
|
@ -1230,8 +1236,10 @@ static void sendmms_func(void *unused)
|
||||||
data_url = octstr_duplicate(data); /* the URL of the message. */
|
data_url = octstr_duplicate(data); /* the URL of the message. */
|
||||||
data = reply;
|
data = reply;
|
||||||
|
|
||||||
|
http_destroy_headers(reqh);
|
||||||
http_destroy_headers(rh);
|
http_destroy_headers(rh);
|
||||||
http_destroy_headers(rph);
|
rh = rph; /* replace as real reply headers. */
|
||||||
|
skip_ctype = 1;
|
||||||
octstr_destroy(params);
|
octstr_destroy(params);
|
||||||
} else if ((data = http_cgi_variable(cgivars, "content")) != NULL) { /* any content. */
|
} else if ((data = http_cgi_variable(cgivars, "content")) != NULL) { /* any content. */
|
||||||
Octstr *_xctype = NULL; /* ... because cgi var stuff is destroyed elsewhere, we must dup it !! */
|
Octstr *_xctype = NULL; /* ... because cgi var stuff is destroyed elsewhere, we must dup it !! */
|
||||||
|
@ -1259,13 +1267,14 @@ static void sendmms_func(void *unused)
|
||||||
lto = octstr_split_words(to);
|
lto = octstr_split_words(to);
|
||||||
|
|
||||||
/* Build the fake reply headers. */
|
/* Build the fake reply headers. */
|
||||||
if (ctype)
|
if (ctype && !skip_ctype)
|
||||||
http_header_add(rh, "Content-Type", octstr_get_cstr(ctype));
|
http_header_add(rh, "Content-Type", octstr_get_cstr(ctype));
|
||||||
|
|
||||||
if ((from = http_cgi_variable(cgivars, "from")) != NULL) {
|
if ((from = http_cgi_variable(cgivars, "from")) != NULL) {
|
||||||
from = octstr_duplicate(from);
|
from = octstr_duplicate(from);
|
||||||
_mms_fixup_address(&from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL, 1);
|
_mms_fixup_address(&from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL, 1);
|
||||||
http_header_add(rh, "X-Mbuni-From", octstr_get_cstr(from));
|
if (from)
|
||||||
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-From", octstr_get_cstr(from));
|
||||||
octstr_destroy(from);
|
octstr_destroy(from);
|
||||||
} else if (!u->faked_sender)
|
} else if (!u->faked_sender)
|
||||||
rb = octstr_imm("Missing Sender address");
|
rb = octstr_imm("Missing Sender address");
|
||||||
|
@ -1278,27 +1287,27 @@ static void sendmms_func(void *unused)
|
||||||
gwlist_destroy(lto, (gwlist_item_destructor_t *)octstr_destroy);
|
gwlist_destroy(lto, (gwlist_item_destructor_t *)octstr_destroy);
|
||||||
}
|
}
|
||||||
if (dlr_url)
|
if (dlr_url)
|
||||||
http_header_add(rh, "X-Mbuni-DLR-Url", octstr_get_cstr(dlr_url));
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-DLR-Url", octstr_get_cstr(dlr_url));
|
||||||
|
|
||||||
if (rr_url)
|
if (rr_url)
|
||||||
http_header_add(rh, "X-Mbuni-RR-Url", octstr_get_cstr(rr_url));
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-RR-Url", octstr_get_cstr(rr_url));
|
||||||
|
|
||||||
if (allow_adaptations)
|
if (allow_adaptations)
|
||||||
http_header_add(rh, "X-Mbuni-Allow-Adaptations",
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-Allow-Adaptations",
|
||||||
(octstr_str_compare(allow_adaptations, "1") == 0) ?
|
(octstr_str_compare(allow_adaptations, "1") == 0) ?
|
||||||
"true" : "false");
|
"true" : "false");
|
||||||
if (mmc)
|
if (mmc)
|
||||||
http_header_add(rh, "X-Mbuni-MMSC", octstr_get_cstr(mmc));
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-MMSC", octstr_get_cstr(mmc));
|
||||||
|
|
||||||
if (subject)
|
if (subject)
|
||||||
http_header_add(rh, "X-Mbuni-Subject", octstr_get_cstr(subject));
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-Subject", octstr_get_cstr(subject));
|
||||||
|
|
||||||
if (mclass)
|
if (mclass)
|
||||||
http_header_add(rh, "X-Mbuni-MessageClass", octstr_get_cstr(mclass));
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-MessageClass", octstr_get_cstr(mclass));
|
||||||
if (prio)
|
if (prio)
|
||||||
http_header_add(rh, "X-Mbuni-Priority", octstr_get_cstr(prio));
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-Priority", octstr_get_cstr(prio));
|
||||||
if (distro)
|
if (distro)
|
||||||
http_header_add(rh, "X-Mbuni-DistributionIndicator", octstr_get_cstr(distro));
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-DistributionIndicator", octstr_get_cstr(distro));
|
||||||
|
|
||||||
/* Requests to make_and_queue below can block, but for now we don't care. */
|
/* Requests to make_and_queue below can block, but for now we don't care. */
|
||||||
if (ctype && data && !rb) { /* only send if no error. */
|
if (ctype && data && !rb) { /* only send if no error. */
|
||||||
|
@ -1307,7 +1316,7 @@ static void sendmms_func(void *unused)
|
||||||
Octstr *transid = NULL;
|
Octstr *transid = NULL;
|
||||||
if (!send_as_incoming) { /* for outgoing, track TransactionID for DLR. */
|
if (!send_as_incoming) { /* for outgoing, track TransactionID for DLR. */
|
||||||
transid = mms_maketransid(NULL, octstr_imm(MM_NAME));
|
transid = mms_maketransid(NULL, octstr_imm(MM_NAME));
|
||||||
http_header_add(rh, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
|
HTTP_REPLACE_HEADER(rh, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
|
||||||
}
|
}
|
||||||
res = make_and_queue_msg(data, ctype, rh,
|
res = make_and_queue_msg(data, ctype, rh,
|
||||||
data_url ? data_url : base_url,
|
data_url ? data_url : base_url,
|
||||||
|
|
Loading…
Reference in New Issue