MINOR: http: add baseq sample fetch
Symetrical to path/pathq, baseq returns the concatenation of
the Host header and the path including the query string.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 00981cc..a5ab659 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -18476,6 +18476,12 @@
depending on the source address family. This can be used to track per-IP,
per-URL counters.
+baseq : string
+ This returns the concatenation of the first Host header and the path part of
+ the request with the query-string, which starts at the first slash. Using this
+ instead of "base" allows one to properly identify the target resource, for
+ statistics or caching use cases. See also "path", "pathq" and "base".
+
capture.req.hdr(<idx>) : string
This extracts the content of the header captured by the "capture request
header", idx is the position of the capture keyword in the configuration.
diff --git a/src/http_fetch.c b/src/http_fetch.c
index 6913d06..8e74765 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -1040,7 +1040,7 @@
sl = http_get_stline(htx);
path = http_get_path(htx_sl_req_uri(sl));
- if (kw[0] == 'p' && kw[4] == 'q') // pathq
+ if (kw[4] == 'q' && (kw[0] == 'p' || kw[0] == 'b')) // pathq or baseq
path = http_get_path(htx_sl_req_uri(sl));
else
path = iststop(http_get_path(htx_sl_req_uri(sl)), '?');
@@ -1089,8 +1089,12 @@
if (isttest(path)) {
size_t len;
- for (len = 0; len < path.len && *(path.ptr + len) != '?'; len++)
- ;
+ if (kw[4] == 'q' && kw[0] == 'b') { // baseq
+ len = path.len;
+ } else {
+ for (len = 0; len < path.len && *(path.ptr + len) != '?'; len++)
+ ;
+ }
if (len && *(path.ptr) == '/')
chunk_memcat(temp, path.ptr, len);
@@ -2044,6 +2048,7 @@
{ "base", smp_fetch_base, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "base32", smp_fetch_base32, 0, NULL, SMP_T_SINT, SMP_USE_HRQHV },
{ "base32+src", smp_fetch_base32_src, 0, NULL, SMP_T_BIN, SMP_USE_HRQHV },
+ { "baseq", smp_fetch_base, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
/* capture are allocated and are permanent in the stream */
{ "capture.req.hdr", smp_fetch_capture_req_hdr, ARG1(1,SINT), NULL, SMP_T_STR, SMP_USE_HRQHP },