How to remove httpheader added via CURLOPT?

Hello.

I’m integrating Asterisk with ntfy to send push notifications on incoming calls to mobile clients to wake up baresip. As part of that I’d like to send two notifications within the same channel, one is a wake-up notification (consumed by Tasker to open baresip), and the other one in case the call is missed, which would be actually displayed on a mobile client.

To do that, I call channel.CURL() with ntfy endpoint specified (note I use Lua dialplan), and before this call I set up ntfy-related HTTP headers like this: channel["CURLOPT(httpheader)"]:set("Title: " .. msg_title). For two different notifications I’d like to have two different titles, and this is ruled by this very HTTP header.

The problem is that within the same channel the HTTP headers set by CURLOPT just add up (as documented, no complaints), there’s no way to remove what was added before (I studied the documentation and the code to my best extent and didn’t find such a possibility), and then ntfy client gets all those headers and just uses the first one meaning what was added later gets ignored.

So, the question is: is it in fact possible to remove/replace specific HTTP header added via CURLOPT in the same channel, and if so, how? Or is there a way to just reset everything added via CURLOPT? And if not, is there any clever workaround?

Thanks.

There isn’t. There’s an open issue[1] somewhat along the lines, with the core issue being no way to really reset things.

[1] [bug]: func_curl adding duplicate header leaves request in bad format · Issue #135 · asterisk/asterisk · GitHub

I see, thank you for your reply. I’ll reference this thread in the bug then and add myself as a watcher.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.