summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_request.c
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2022-07-14 04:32:49 +0800
committerZhidao HONG <z.hong@f5.com>2022-07-14 04:32:49 +0800
commit45b89e32577eef18e473d0c7ae24562e7efedcc0 (patch)
treed7058ec9ad0fb257897873cc1429182425d17b9b /src/nxt_http_request.c
parent7b80186f097fda3d1c0758a30efa889ec89c5a9d (diff)
downloadunit-45b89e32577eef18e473d0c7ae24562e7efedcc0.tar.gz
unit-45b89e32577eef18e473d0c7ae24562e7efedcc0.tar.bz2
Var: dynamic variables support.
This commit adds the variables $arg_NAME, $header_NAME, and $cookie_NAME.
Diffstat (limited to 'src/nxt_http_request.c')
-rw-r--r--src/nxt_http_request.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/nxt_http_request.c b/src/nxt_http_request.c
index 8aa20e59..5f8fd8f7 100644
--- a/src/nxt_http_request.c
+++ b/src/nxt_http_request.c
@@ -1180,3 +1180,57 @@ end:
return nxt_http_field_hash_end(hash) & 0xFFFF;
}
+
+
+int64_t
+nxt_http_argument_hash(nxt_mp_t *mp, nxt_str_t *name)
+{
+ return nxt_http_field_hash(mp, name, 1, NXT_HTTP_URI_ENCODING_PLUS);
+}
+
+
+int64_t
+nxt_http_header_hash(nxt_mp_t *mp, nxt_str_t *name)
+{
+ u_char c, *p;
+ uint32_t i, hash;
+ nxt_str_t str;
+
+ str.length = name->length;
+
+ str.start = nxt_mp_nget(mp, str.length);
+ if (nxt_slow_path(str.start == NULL)) {
+ return -1;
+ }
+
+ p = str.start;
+ hash = NXT_HTTP_FIELD_HASH_INIT;
+
+ for (i = 0; i < name->length; i++) {
+ c = name->start[i];
+
+ if (c >= 'A' && c <= 'Z') {
+ *p = c | 0x20;
+
+ } else if (c == '_') {
+ *p = '-';
+
+ } else {
+ *p = c;
+ }
+
+ hash = nxt_http_field_hash_char(hash, *p);
+ p++;
+ }
+
+ *name = str;
+
+ return nxt_http_field_hash_end(hash) & 0xFFFF;
+}
+
+
+int64_t
+nxt_http_cookie_hash(nxt_mp_t *mp, nxt_str_t *name)
+{
+ return nxt_http_field_hash(mp, name, 1, NXT_HTTP_URI_ENCODING_NONE);
+}