[mod_sofia] Set the proper content-length for multipart messages

Before any custom headers set via `sip_multipart` would be included in the size calculation.
This commit is contained in:
Andrew Querol 2021-01-11 15:17:17 -06:00 committed by root
parent ac5775b6e0
commit ffee18ff82
1 changed files with 4 additions and 1 deletions

View File

@ -104,7 +104,10 @@ static void process_mp(switch_core_session_t *session, switch_stream_handle_t *s
if ((dval = strchr(dname, ':'))) {
*dval++ = '\0';
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);
char *body;
if ((body = strstr(dval, "\r\n\r\n"))) {
stream->write_function(stream, "--%s\r\nContent-Type: %s\r\nContent-Length: %d\r\n%s\r\n", boundary, dname, strlen(body + 4) + 1, dval + 1);
}
} 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);
}