Module: kamailio
Branch: master
Commit: 6948a3cc1f81cd468eae92518215d0fe9178b1e7
URL:
https://github.com/kamailio/kamailio/commit/6948a3cc1f81cd468eae92518215d0f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-02-23T12:18:07+01:00
microhttpd: added the header return option for pv
---
Modified: src/modules/microhttpd/microhttpd_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6948a3cc1f81cd468eae92518215d0f…
Patch:
https://github.com/kamailio/kamailio/commit/6948a3cc1f81cd468eae92518215d0f…
---
diff --git a/src/modules/microhttpd/microhttpd_mod.c
b/src/modules/microhttpd/microhttpd_mod.c
index 692c9e752e2..f1ee8334b8b 100644
--- a/src/modules/microhttpd/microhttpd_mod.c
+++ b/src/modules/microhttpd/microhttpd_mod.c
@@ -236,6 +236,13 @@ int pv_parse_mhttpd_name(pv_spec_p sp, str *in)
}
break;
default:
+ if(in->len > 2 && in->s[1] == ':'
+ && (in->s[0] == 'h' || in->s[0] == 'H')) {
+ sp->pvp.pvn.type = PV_NAME_INTSTR;
+ sp->pvp.pvn.u.isname.type = PVT_HDR;
+ sp->pvp.pvn.u.isname.name.s = *in;
+ return 0;
+ }
goto error;
}
sp->pvp.pvn.type = PV_NAME_INTSTR;
@@ -254,12 +261,23 @@ int pv_parse_mhttpd_name(pv_spec_p sp, str *in)
int pv_get_mhttpd(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
{
struct sockaddr *srcaddr = NULL;
+ const char *hdrval = NULL;
+
if(param == NULL) {
return -1;
}
if(_ksr_mhttpd_ctx.connection == NULL) {
return pv_get_null(msg, param, res);
}
+ if(param->pvn.u.isname.type == PVT_HDR) {
+ hdrval = MHD_lookup_connection_value(_ksr_mhttpd_ctx.connection,
+ MHD_HEADER_KIND, param->pvn.u.isname.name.s.s + 2);
+ if(hdrval == NULL) {
+ return pv_get_null(msg, param, res);
+ }
+ return pv_get_strzval(msg, param, res, (char *)hdrval);
+ }
+
switch(param->pvn.u.isname.name.n) {
case 0: /* url */
return pv_get_strval(msg, param, res, &_ksr_mhttpd_ctx.url);