[asterisk-dev] Adding headers to NOTIFY responses

Joshua C. Colp jcolp at sangoma.com
Tue Nov 15 08:56:44 CST 2022


On Tue, Nov 15, 2022 at 10:50 AM <asterisk at phreaknet.org> wrote:

> I am working on something where I need to be able to add a custom header
> to an outgoing NOTIFY response for a subscription.
>
> We have the concept of "body generators" for adding stuff to the body of
> an outgoing NOTIFY, but I'm not seeing anything akin to "header
> generators" that would easily allow doing this.
>
> I believe typically this is done by adding the header to the tdata pool,
> e.g. ast_sip_add_header(tdata, "Expires", buf) as one way of doing it.
>

To be specific, it allocates a header FROM the tdata pool and sets it on
tdata.


>
> However, res_pjsip_pubsub doesn't generate/initialize a pjsip_tx_data
> until after ast_sip_subscription_notify is already called, so it
> certainly can't be done before a pubsub module calls on the pubsub core
> to send the notify. Is there any way I've missed that allows us to
> access the tdata from a pubsub module, so we can add a header to the
> NOTIFY response?
>

No.


>
> I do see there is an ast_sip_subscription_response_data struct defined
> in res_pjsip_pubsub.h. However, this is used literally nowhere in the
> code, only defined, so it's not clear to me how this is supposed to be
> used, since nothing currently uses it. Was this intended to be used for
> this purpose, or something else?
>

What you see is the information there is.


>
> If res_pjsip_pubsub would need to be extended to support this, would it
> reasonable to add a callback to a pubsub module that allows it access to
> the pjsip_tx_data, so it can do whatever it needs to with it, before the
> response gets sent? Or another preferred method of allowing modules to
> add headers?
>

At a surface it is probably fine.

-- 
Joshua C. Colp
Asterisk Project Lead
Sangoma Technologies
Check us out at www.sangoma.com and www.asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20221115/a6ebb74c/attachment.html>


More information about the asterisk-dev mailing list