Module: kamailio
Branch: master
Commit: 2b8d587713d96fbee31534b9b16f2c2b432e2e68
URL:
https://github.com/kamailio/kamailio/commit/2b8d587713d96fbee31534b9b16f2c2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-04-12T21:59:44+02:00
nghttp2: added $nghttp2(pathfull) - full http path with all params
---
Modified: src/modules/nghttp2/nghttp2_mod.c
Modified: src/modules/nghttp2/nghttp2_server.c
Modified: src/modules/nghttp2/nghttp2_server.h
---
Diff:
https://github.com/kamailio/kamailio/commit/2b8d587713d96fbee31534b9b16f2c2…
Patch:
https://github.com/kamailio/kamailio/commit/2b8d587713d96fbee31534b9b16f2c2…
---
diff --git a/src/modules/nghttp2/nghttp2_mod.c b/src/modules/nghttp2/nghttp2_mod.c
index 95918b1e6c8..c3e05e50b05 100644
--- a/src/modules/nghttp2/nghttp2_mod.c
+++ b/src/modules/nghttp2/nghttp2_mod.c
@@ -218,6 +218,14 @@ int pv_parse_nghttp2_name(pv_spec_p sp, str *in)
goto error;
}
break;
+ case 8:
+ if(strncasecmp(in->s, "pathfull", 8) == 0) {
+ sp->pvp.pvn.u.isname.name.n = 6;
+ } else {
+ goto error;
+ }
+ break;
+
default:
if(in->len > 2 && in->s[1] == ':'
&& (in->s[0] == 'h' || in->s[0] == 'H')) {
@@ -275,6 +283,9 @@ int pv_get_nghttp2(sip_msg_t *msg, pv_param_t *param, pv_value_t
*res)
return pv_get_strval(msg, param, res, &_ksr_nghttp2_ctx.srcip);
}
return pv_get_null(msg, param, res);
+ case 6: /* pathfull */
+ return pv_get_strval(msg, param, res, &_ksr_nghttp2_ctx.pathfull);
+
default:
return pv_get_null(msg, param, res);
}
diff --git a/src/modules/nghttp2/nghttp2_server.c b/src/modules/nghttp2/nghttp2_server.c
index dec339d7a15..8c17f847f87 100644
--- a/src/modules/nghttp2/nghttp2_server.c
+++ b/src/modules/nghttp2/nghttp2_server.c
@@ -179,7 +179,12 @@ static void delete_http2_stream_data(http2_stream_data *stream_data)
close(stream_data->fd);
}
free(stream_data->request_path);
- free(stream_data->request_method);
+ if(stream_data->request_pathfull) {
+ free(stream_data->request_pathfull);
+ }
+ if(stream_data->request_method) {
+ free(stream_data->request_method);
+ }
free(stream_data);
}
@@ -460,6 +465,7 @@ static int on_header_callback(nghttp2_session *session,
for(j = 0; j < valuelen && value[j] != '?'; ++j)
;
stream_data->request_path = percent_decode(value, j);
+ stream_data->request_pathfull = percent_decode(value, valuelen);
} else if(namelen == sizeof(METHOD) - 1
&& memcmp(METHOD, name, namelen) == 0) {
if(stream_data->request_method) {
diff --git a/src/modules/nghttp2/nghttp2_server.h b/src/modules/nghttp2/nghttp2_server.h
index 34e6155abfc..cad3772d9ef 100644
--- a/src/modules/nghttp2/nghttp2_server.h
+++ b/src/modules/nghttp2/nghttp2_server.h
@@ -70,6 +70,7 @@ typedef struct http2_stream_data
{
struct http2_stream_data *prev, *next;
char *request_path;
+ char *request_pathfull;
char *request_method;
int32_t stream_id;
int fd;
@@ -100,6 +101,7 @@ typedef struct ksr_nghttp2_ctx
int rplhdrs_n;
str method;
str path;
+ str pathfull;
str httpversion;
str data;
char srcipbuf[IP_ADDR_MAX_STR_SIZE];