[SR-Users] Add extra headers on HTTP requests in Kamailio v5

Joel Serrano joel at gogii.net
Thu Jun 29 20:47:57 CEST 2017

Hi all,

Is there a way to add extra headers with http_client_query() from
http_client module?

In current http_query() from utils module, according to the doc, you can
add a custom header:

*4. Functions*

*4.1.  http_query(url, [post-data], [header-data], result)*

*If you want to add additional headers to the request, you have to define
the “header”-data, that should be submitted in that request as the third
parameter. If this parameter is empty, it is not set.*

and I have that working with the following:

http_query("https://example.com/api", "param1=value1&param2=value2",
"Cookie: apikey=super_secret_api_key", "$var(call_info)");

The problem is that http_query() is removed in Kamailio v5, and the
http_client_query() only has the ability to add specifically the
content-type header:

*4. Functions*

*4.1.  http_connect(connection, url, [content_type, data,] result)*

*content_type - Used only when posting data with HTTP POST. An Internet
Media type, like "application/json" or "text/plain". Will be added to the
HTTP request as a header.*

Is there another way to add a custom header to a http request with the
http_client module?

Any workarounds for this?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20170629/0610eb7e/attachment.html>

More information about the sr-users mailing list