Hi,

yes at the end of the game I've introduced a small kemi script in python which exposes a generic http client for use in the classic config script. Unfortunately if you don't use a full kemi config you just have an _exec method with only one arg, so had to leverage multiple avp to pass more than one param. 

Maybe in the future I will migrate the entire config to kemi but right now is too much work :)

Thanks,
Matteo

PS:
Will love to see a "cascading" config framework... to mix different config providers and fallback, this may ease a lot migration from classic to kemi.


On Sat, Sep 16, 2023 at 8:19 PM Karsten Horsmann <khorsmann@gmail.com> wrote:
Hi,

Maybe an kemi script would be an good choice here? So you can choose from different script languages that kemi supports (Lua, python, js and many more that I forgot)? You can also mix classic Kamailio scripting language with kemi if that http request is the only business logic that need more complex stuff. 



Matteo Brancaleoni <mbrancaleoni@gmail.com> schrieb am Mi., 13. Sept. 2023, 10:31:
Ok,

seems that the Content-Type is added automatically by libcurl when performing a POST request, unless it detects an already present hdr in the headers params.

Seems that inverting the order of headers, so building the string with "Content-Type: application/json\r\nAuthorization: Bearer sometoken" seems to work, probably because libcurl detects the header and does not add it's own.

But this is something "magic", not documented and prone to breakage, since for libcurl headers should be a linked list of strings.

What do you suggest to properly handle that? Use scripting? Propose a patch to split the headers string into a libcurl linked list?

br,
Mat

On Tue, Sep 12, 2023 at 5:53 PM Matteo Brancaleoni <mbrancaleoni@gmail.com> wrote:
Hello all :)

I'm struggling to add two headers to an http client request, but cannot find a proper way to do it.

The headers are Authorization and Content-Type.

The first try is with http_client module, beside undocumented, is possible to add multiple headers separating them with "\r\n". What I see is the correct Authorization header, and two Content-Type headers, one with my content type the other with x-www-form-urlencoded, which no one sets ?

Second try is with http_async_client which supports multiple headers, but since I'm calling it from an xhttp event route, there's no transaction and request cannot be suspended, so I cannot get results before sending out xhttp response...

Any hint?

br, 
Mat
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe: