Skip to content

Commit

Permalink
nghttp2: added $nghttp2(pathfull) - full http path with all params
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Apr 12, 2024
1 parent 8bc64a9 commit 2b8d587
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/modules/nghttp2/nghttp2_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 7 additions & 1 deletion src/modules/nghttp2/nghttp2_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/modules/nghttp2/nghttp2_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 2b8d587

Please sign in to comment.