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);
25
26static nxt_int_t nxt_http_field_hash_collision(nxt_lvlhsh_query_t *lhq,
27 void *data);
28
29
30#define NXT_HTTP_MAX_FIELD_NAME 0xFF
31#define NXT_HTTP_MAX_FIELD_VALUE NXT_INT32_T_MAX
32

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

1126 return NXT_OK;
1127}
1128
1129
1130const nxt_lvlhsh_proto_t nxt_http_fields_hash_proto nxt_aligned(64) = {
1131 NXT_LVLHSH_BUCKET_SIZE(64),
1132 { NXT_HTTP_FIELD_LVLHSH_SHIFT, 0, 0, 0, 0, 0, 0, 0 },
1133 nxt_http_field_hash_test,
1134 nxt_lvlhsh_alloc,
1135 nxt_lvlhsh_free,
1136};
1137
1138
1139static nxt_int_t
1140nxt_http_field_hash_test(nxt_lvlhsh_query_t *lhq, void *data)
1141{
1142 nxt_http_field_proc_t *field;
1143
1144 field = data;
1145
1146 if (nxt_strcasestr_eq(&lhq->key, &field->name)) {
1147 return NXT_OK;
1148 }
1149
1150 return NXT_DECLINED;
1151}
1152
1153
1154static nxt_int_t
1155nxt_http_field_hash_collision(nxt_lvlhsh_query_t *lhq, void *data)
1156{
1157 return NXT_OK;
1158}
1159
1160
1161nxt_int_t
1162nxt_http_fields_hash(nxt_lvlhsh_t *hash,
1163 nxt_http_field_proc_t items[], nxt_uint_t count)
1164{
1165 u_char ch;
1166 uint32_t key;
1167 nxt_str_t *name;
1168 nxt_int_t ret;
1169 nxt_uint_t i, j;
1170 nxt_lvlhsh_query_t lhq;
1171
1172 lhq.replace = 0;
1173 lhq.proto = &nxt_http_fields_hash_proto;
1174
1175 for (i = 0; i < count; i++) {
1176 key = NXT_HTTP_FIELD_HASH_INIT;
1177 name = &items[i].name;
1178
1179 for (j = 0; j < name->length; j++) {
1180 ch = nxt_lowcase(name->start[j]);
1181 key = nxt_http_field_hash_char(key, ch);

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

1192 }
1193 }
1194
1195 return NXT_OK;
1196}
1197
1198
1199nxt_uint_t
1200nxt_http_fields_hash_collisions(nxt_lvlhsh_t *hash,
1201 nxt_http_field_proc_t items[], nxt_uint_t count, nxt_bool_t level)
1202{
1203 u_char ch;
1204 uint32_t key, mask;
1205 nxt_str_t *name;
1206 nxt_uint_t colls, i, j;
1207 nxt_lvlhsh_proto_t proto;
1208 nxt_lvlhsh_query_t lhq;
1209
1210 proto = nxt_http_fields_hash_proto;
1211 proto.test = nxt_http_field_hash_collision;
1212
1213 lhq.replace = 0;
1214 lhq.proto = &proto;
1215
1216 mask = level ? (1 << NXT_HTTP_FIELD_LVLHSH_SHIFT) - 1 : 0xFFFF;
1217
1218 colls = 0;
1219
1220 for (i = 0; i < count; i++) {
1221 key = NXT_HTTP_FIELD_HASH_INIT;
1222 name = &items[i].name;

--- 35 unchanged lines hidden ---