Fixed content-length for multipart bodies and moved sdp to first body
This commit is contained in:
parent
c6452cc8da
commit
f9d04ba761
|
@ -102,9 +102,16 @@ static void process_mp(switch_core_session_t *session, switch_stream_handle_t *s
|
||||||
if ((dval = strchr(dname, ':'))) {
|
if ((dval = strchr(dname, ':'))) {
|
||||||
*dval++ = '\0';
|
*dval++ = '\0';
|
||||||
if (*dval == '~') {
|
if (*dval == '~') {
|
||||||
stream->write_function(stream, "--%s\r\nContent-Type: %s\r\nContent-Length: %d\r\n%s\r\n", boundary, dname, strlen(dval), dval + 1);
|
int dlen;
|
||||||
|
char *bstart = strstr(dval, "\r\n\r\n");
|
||||||
|
if (bstart != NULL) {
|
||||||
|
dlen = strlen(bstart) - 4;
|
||||||
|
} else {
|
||||||
|
dlen = strlen(dval) - 1;
|
||||||
|
}
|
||||||
|
stream->write_function(stream, "--%s\r\nContent-Type: %s\r\nContent-Length: %d\r\n%s\r\n", boundary, dname, dlen, dval + 1);
|
||||||
} else {
|
} else {
|
||||||
stream->write_function(stream, "--%s\r\nContent-Type: %s\r\nContent-Length: %d\r\n\r\n%s\r\n", boundary, dname, strlen(dval) + 1, dval);
|
stream->write_function(stream, "--%s\r\nContent-Type: %s\r\nContent-Length: %d\r\n\r\n%s\r\n", boundary, dname, strlen(dval), dval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,6 +132,12 @@ char *sofia_media_get_multipart(switch_core_session_t *session, const char *pref
|
||||||
char *value = (char *) hi->value;
|
char *value = (char *) hi->value;
|
||||||
|
|
||||||
if (!strcasecmp(name, prefix)) {
|
if (!strcasecmp(name, prefix)) {
|
||||||
|
if (x == 0) {
|
||||||
|
*mp_type = switch_core_session_sprintf(session, "multipart/mixed; boundary=%s", boundary);
|
||||||
|
if (sdp) {
|
||||||
|
stream.write_function(&stream, "--%s\r\nContent-Type: application/sdp\r\nContent-Length: %d\r\n\r\n%s\r\n", boundary, strlen(sdp) + 1, sdp);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (hi->idx > 0) {
|
if (hi->idx > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -142,10 +155,6 @@ char *sofia_media_get_multipart(switch_core_session_t *session, const char *pref
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x) {
|
if (x) {
|
||||||
*mp_type = switch_core_session_sprintf(session, "multipart/mixed; boundary=%s", boundary);
|
|
||||||
if (sdp) {
|
|
||||||
stream.write_function(&stream, "--%s\r\nContent-Type: application/sdp\r\nContent-Length: %d\r\n\r\n%s\r\n", boundary, strlen(sdp) + 1, sdp);
|
|
||||||
}
|
|
||||||
stream.write_function(&stream, "--%s--\r\n", boundary);
|
stream.write_function(&stream, "--%s--\r\n", boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue