path_reg : regex match
path_sub : substring match
+pathq : string
+ This extracts the request's URL path with the query-string, which starts at
+ the first slash. This sample fetch is pretty handy to always retrieve a
+ relative URI, excluding the scheme and the authority part, if any. Indeed,
+ while it is the common representation for an HTTP/1.1 request target, in
+ HTTP/2, an absolute URI is often used. This sample fetch will return the same
+ result in both cases.
+
query : string
This extracts the request's query string, which starts after the first
question mark. If no question mark is present, this fetch returns nothing. If
return ret;
}
-/* 8. Check on URI PATH. A pointer to the PATH is stored. The path starts at
- * the first '/' after the possible hostname, and ends before the possible '?'.
+/* 8. Check on URI PATH. A pointer to the PATH is stored. The path starts at the
+ * first '/' after the possible hostname. It ends before the possible '?' except
+ * for 'pathq' keyword.
*/
static int smp_fetch_path(const struct arg *args, struct sample *smp, const char *kw, void *private)
{
return 0;
sl = http_get_stline(htx);
- path = iststop(http_get_path(htx_sl_req_uri(sl)), '?');
+ path = http_get_path(htx_sl_req_uri(sl));
+
+ if (kw[0] == 'p' && kw[4] == 'q') // pathq
+ path = http_get_path(htx_sl_req_uri(sl));
+ else
+ path = iststop(http_get_path(htx_sl_req_uri(sl)), '?');
+
if (!isttest(path))
return 0;
{ "http_first_req", smp_fetch_http_first_req, 0, NULL, SMP_T_BOOL, SMP_USE_HRQHP },
{ "method", smp_fetch_meth, 0, NULL, SMP_T_METH, SMP_USE_HRQHP },
{ "path", smp_fetch_path, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
+ { "pathq", smp_fetch_path, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "query", smp_fetch_query, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
/* HTTP protocol on the request path */