parse_request(dst);
}
+/* add a blank line if no body */
+static void add_blank(struct sip_request *req)
+{
+ if (!req->lines) {
+ /* Add extra empty return. add_header() reserves 4 bytes so cannot be truncated */
+ snprintf(req->data + req->len, sizeof(req->data) - req->len, "\r\n");
+ req->len += strlen(req->data + req->len);
+ }
+}
+
/*! \brief Transmit response on SIP request*/
static int send_response(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, int seqno)
{
int res;
+ add_blank(req);
if (sip_debug_test_pvt(p)) {
char iabuf[INET_ADDRSTRLEN];
if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
{
int res;
+ add_blank(req);
if (sip_debug_test_pvt(p)) {
char iabuf[INET_ADDRSTRLEN];
if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
snprintf(buf, sizeof(buf), "%d", p->owner->hangupcause);
add_header(&resp, "X-Asterisk-HangupCauseCode", buf);
}
- add_blank_header(&resp);
return send_response(p, &resp, reliable, seqno);
}
respprep(&resp, p, msg, req);
append_date(&resp);
add_header_contentLength(&resp, 0);
- add_blank_header(&resp);
return send_response(p, &resp, XMIT_UNRELIABLE, 0);
}
respprep(&resp, p, msg, req);
add_header(&resp, "Accept", "application/sdp");
add_header_contentLength(&resp, 0);
- add_blank_header(&resp);
return send_response(p, &resp, reliable, 0);
}
respprep(&resp, p, msg, req);
add_header(&resp, header, tmp);
add_header_contentLength(&resp, 0);
- add_blank_header(&resp);
return send_response(p, &resp, reliable, seqno);
}
add_sdp(&req, p);
} else {
add_header_contentLength(&req, 0);
- add_blank_header(&req);
}
if (!p->initreq.headers)
add_header(&req, "Contact", p->our_contact);
add_header(&req, "Event", "registration");
add_header_contentLength(&req, 0);
- add_blank_header(&req);
initialize_initreq(p, &req);
if (sip_debug_test_pvt(p))
add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
if (!ast_strlen_zero(p->our_contact))
add_header(&req, "Referred-By", p->our_contact);
- add_blank_header(&req);
return send_request(p, &req, 1, p->ocseq);
/* We should propably wait for a NOTIFY here until we ack the transfer */
struct sip_request resp;
reqprep(&resp, p, sipmethod, seqno, newbranch);
add_header_contentLength(&resp, 0);
- add_blank_header(&resp);
return send_request(p, &resp, reliable, seqno ? seqno : p->ocseq);
}
}
add_header_contentLength(&resp, 0);
- add_blank_header(&resp);
return send_request(p, &resp, reliable, seqno ? seqno : p->ocseq);
}