nxt_http_parse.c (1270:9efa309be18b) nxt_http_parse.c (1459:358b957ca294)
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);
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,
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,
1136 nxt_http_field_hash_alloc,
1137 nxt_http_field_hash_free,
1134 nxt_lvlhsh_alloc,
1135 nxt_lvlhsh_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
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
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
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
1178nxt_http_fields_hash(nxt_lvlhsh_t *hash, nxt_mp_t *mp,
1162nxt_http_fields_hash(nxt_lvlhsh_t *hash,
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;
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;
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
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
1217nxt_http_fields_hash_collisions(nxt_lvlhsh_t *hash, nxt_mp_t *mp,
1200nxt_http_fields_hash_collisions(nxt_lvlhsh_t *hash,
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;
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;
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 ---
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 ---