瀏覽代碼

nghttp2: added $nghttp2(pathfull) - full http path with all params

Daniel-Constantin Mierla 1 年之前
父節點
當前提交
2b8d587713
共有 3 個文件被更改,包括 20 次插入1 次删除
  1. 11 0
      src/modules/nghttp2/nghttp2_mod.c
  2. 7 1
      src/modules/nghttp2/nghttp2_server.c
  3. 2 0
      src/modules/nghttp2/nghttp2_server.h

+ 11 - 0
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);
 	}

+ 7 - 1
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) {

+ 2 - 0
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];