Index: res/res_pjsip_exten_state.c =================================================================== --- res/res_pjsip_exten_state.c (revision 405280) +++ res/res_pjsip_exten_state.c (working copy) @@ -117,7 +117,22 @@ ao2_cleanup(sub->sip_sub); } +#define DEFAULT_PRESENCE_BODY "application/pidf+xml" + /*! + * This serves the purpose of taking the place of an Accept header + * if one cannot be found in an incoming SUBSCRIBE. This only + * defines the header value and cannot be treated the same as + * other run-of-the mill Accept headers. + */ +static pjsip_accept_hdr default_presence_accept = { + .count = 1, + .values = { + { .ptr = DEFAULT_PRESENCE_BODY, .slen = sizeof(DEFAULT_PRESENCE_BODY) - 1 }, + }, +}; + +/*! * \internal * \brief Copies the body types the message wishes to subscribe to. */ @@ -128,6 +143,12 @@ pjsip_accept_hdr *hdr = (pjsip_accept_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_ACCEPT, NULL); + if (!hdr) { + /* No Accept header means to use the default accept header for + * presence + */ + hdr = &default_presence_accept; + } exten_state_sub->body_types_count = hdr->count; exten_state_sub->body_types = ast_malloc(hdr->count * sizeof(char*)); @@ -527,8 +548,6 @@ exten_state_sub->last_exten_state)); } -#define DEFAULT_PRESENCE_BODY "application/pidf+xml" - /*! * \internal * \brief Create and register a subscription handler.