Deleted Added
1
2/*
3 * Copyright (C) NGINX, Inc.
4 * Copyright (C) Valentin V. Bartenev
5 */
6
7#include <nxt_main.h>
8

--- 8 unchanged lines hidden (view full) ---

17 u_char **pos, u_char *end);
18static u_char *nxt_http_lookup_field_end(u_char *p, u_char *end);
19static nxt_int_t nxt_http_parse_field_end(nxt_http_request_parse_t *rp,
20 u_char **pos, u_char *end);
21
22static nxt_int_t nxt_http_parse_complex_target(nxt_http_request_parse_t *rp);
23
24static nxt_int_t nxt_http_field_hash_test(nxt_lvlhsh_query_t *lhq, void *data);
25static void *nxt_http_field_hash_alloc(void *pool, size_t size);
26static void nxt_http_field_hash_free(void *pool, void *p);
27
28static nxt_int_t nxt_http_field_hash_collision(nxt_lvlhsh_query_t *lhq,
29 void *data);
30
31
32#define NXT_HTTP_MAX_FIELD_NAME 0xFF
33#define NXT_HTTP_MAX_FIELD_VALUE NXT_INT32_T_MAX
34

--- 1093 unchanged lines hidden (view full) ---

1128 return NXT_OK;
1129}
1130
1131
1132const nxt_lvlhsh_proto_t nxt_http_fields_hash_proto nxt_aligned(64) = {
1133 NXT_LVLHSH_BUCKET_SIZE(64),
1134 { NXT_HTTP_FIELD_LVLHSH_SHIFT, 0, 0, 0, 0, 0, 0, 0 },
1135 nxt_http_field_hash_test,
1136 nxt_http_field_hash_alloc,
1137 nxt_http_field_hash_free,
1138};
1139
1140
1141static nxt_int_t
1142nxt_http_field_hash_test(nxt_lvlhsh_query_t *lhq, void *data)
1143{
1144 nxt_http_field_proc_t *field;
1145
1146 field = data;
1147
1148 if (nxt_strcasestr_eq(&lhq->key, &field->name)) {
1149 return NXT_OK;
1150 }
1151
1152 return NXT_DECLINED;
1153}
1154
1155
1156static void *
1157nxt_http_field_hash_alloc(void *pool, size_t size)
1158{
1159 return nxt_mp_align(pool, size, size);
1160}
1161
1162
1163static void
1164nxt_http_field_hash_free(void *pool, void *p)
1165{
1166 nxt_mp_free(pool, p);
1167}
1168
1169
1170static nxt_int_t
1171nxt_http_field_hash_collision(nxt_lvlhsh_query_t *lhq, void *data)
1172{
1173 return NXT_OK;
1174}
1175
1176
1177nxt_int_t
1178nxt_http_fields_hash(nxt_lvlhsh_t *hash, nxt_mp_t *mp,
1179 nxt_http_field_proc_t items[], nxt_uint_t count)
1180{
1181 u_char ch;
1182 uint32_t key;
1183 nxt_str_t *name;
1184 nxt_int_t ret;
1185 nxt_uint_t i, j;
1186 nxt_lvlhsh_query_t lhq;
1187
1188 lhq.replace = 0;
1189 lhq.proto = &nxt_http_fields_hash_proto;
1190 lhq.pool = mp;
1191
1192 for (i = 0; i < count; i++) {
1193 key = NXT_HTTP_FIELD_HASH_INIT;
1194 name = &items[i].name;
1195
1196 for (j = 0; j < name->length; j++) {
1197 ch = nxt_lowcase(name->start[j]);
1198 key = nxt_http_field_hash_char(key, ch);

--- 10 unchanged lines hidden (view full) ---

1209 }
1210 }
1211
1212 return NXT_OK;
1213}
1214
1215
1216nxt_uint_t
1217nxt_http_fields_hash_collisions(nxt_lvlhsh_t *hash, nxt_mp_t *mp,
1218 nxt_http_field_proc_t items[], nxt_uint_t count, nxt_bool_t level)
1219{
1220 u_char ch;
1221 uint32_t key, mask;
1222 nxt_str_t *name;
1223 nxt_uint_t colls, i, j;
1224 nxt_lvlhsh_proto_t proto;
1225 nxt_lvlhsh_query_t lhq;
1226
1227 proto = nxt_http_fields_hash_proto;
1228 proto.test = nxt_http_field_hash_collision;
1229
1230 lhq.replace = 0;
1231 lhq.proto = &proto;
1232 lhq.pool = mp;
1233
1234 mask = level ? (1 << NXT_HTTP_FIELD_LVLHSH_SHIFT) - 1 : 0xFFFF;
1235
1236 colls = 0;
1237
1238 for (i = 0; i < count; i++) {
1239 key = NXT_HTTP_FIELD_HASH_INIT;
1240 name = &items[i].name;

--- 35 unchanged lines hidden ---