Deleted
Added
nxt_http_parse.c (577:000a777d3716) | nxt_http_parse.c (611:323e11065f83) |
---|---|
1 2/* 3 * Copyright (C) NGINX, Inc. 4 * Copyright (C) Valentin V. Bartenev 5 */ 6 7#include <nxt_main.h> 8 --- 15 unchanged lines hidden (view full) --- 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 | 1 2/* 3 * Copyright (C) NGINX, Inc. 4 * Copyright (C) Valentin V. Bartenev 5 */ 6 7#include <nxt_main.h> 8 --- 15 unchanged lines hidden (view full) --- 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 | 32#define NXT_HTTP_MAX_FIELD_NAME 0xFF |
33#define NXT_HTTP_MAX_FIELD_VALUE NXT_INT32_T_MAX 34 35#define NXT_HTTP_FIELD_LVLHSH_SHIFT 5 36 37#define NXT_HTTP_FIELD_HASH_INIT 159406 38#define nxt_http_field_hash_char(h, c) (((h) << 4) + (h) + (c)) 39#define nxt_http_field_hash_end(h) (((h) >> 16) ^ (h)) 40 --- 644 unchanged lines hidden (view full) --- 685 686static u_char * 687nxt_http_lookup_field_end(u_char *p, u_char *end) 688{ 689 while (nxt_fast_path(end - p >= 16)) { 690 691#define nxt_field_end_test_char(ch) \ 692 \ | 33#define NXT_HTTP_MAX_FIELD_VALUE NXT_INT32_T_MAX 34 35#define NXT_HTTP_FIELD_LVLHSH_SHIFT 5 36 37#define NXT_HTTP_FIELD_HASH_INIT 159406 38#define nxt_http_field_hash_char(h, c) (((h) << 4) + (h) + (c)) 39#define nxt_http_field_hash_end(h) (((h) >> 16) ^ (h)) 40 --- 644 unchanged lines hidden (view full) --- 685 686static u_char * 687nxt_http_lookup_field_end(u_char *p, u_char *end) 688{ 689 while (nxt_fast_path(end - p >= 16)) { 690 691#define nxt_field_end_test_char(ch) \ 692 \ |
693 /* Values below 0x20 become more than 0xdf. */ \ 694 if (nxt_slow_path((u_char) ((ch) - 0x20) > 0x5e)) { \ | 693 /* Values below 0x20 become more than 0xDF. */ \ 694 if (nxt_slow_path((u_char) ((ch) - 0x20) > 0x5E)) { \ |
695 return &(ch); \ 696 } 697 698/* enddef */ 699 700 nxt_field_end_test_char(p[0]); 701 nxt_field_end_test_char(p[1]); 702 nxt_field_end_test_char(p[2]); --- 102 unchanged lines hidden (view full) --- 805#define \ 806nxt_http_is_normal(c) \ 807 (nxt_fast_path((nxt_http_normal[c / 8] & (1 << (c & 7))) != 0)) 808 809 810static const uint8_t nxt_http_normal[32] nxt_aligned(32) = { 811 812 /* \0 \r \n */ | 695 return &(ch); \ 696 } 697 698/* enddef */ 699 700 nxt_field_end_test_char(p[0]); 701 nxt_field_end_test_char(p[1]); 702 nxt_field_end_test_char(p[2]); --- 102 unchanged lines hidden (view full) --- 805#define \ 806nxt_http_is_normal(c) \ 807 (nxt_fast_path((nxt_http_normal[c / 8] & (1 << (c & 7))) != 0)) 808 809 810static const uint8_t nxt_http_normal[32] nxt_aligned(32) = { 811 812 /* \0 \r \n */ |
813 0xfe, 0xdb, 0xff, 0xff, /* 1111 1110 1101 1011 1111 1111 1111 1111 */ | 813 0xFE, 0xDB, 0xFF, 0xFF, /* 1111 1110 1101 1011 1111 1111 1111 1111 */ |
814 815 /* '&%$ #"! /.-, |*)( 7654 3210 ?>=< ;:98 */ | 814 815 /* '&%$ #"! /.-, |*)( 7654 3210 ?>=< ;:98 */ |
816 0xd6, 0x37, 0xff, 0x7f, /* 1101 0110 0011 0111 1111 1111 0111 1111 */ | 816 0xD6, 0x37, 0xFF, 0x7F, /* 1101 0110 0011 0111 1111 1111 0111 1111 */ |
817 818 /* GFED CBA@ ONML KJIH WVUT SRQP _^]\ [ZYX */ | 817 818 /* GFED CBA@ ONML KJIH WVUT SRQP _^]\ [ZYX */ |
819 0xff, 0xff, 0xff, 0xff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | 819 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
820 821 /* gfed cba` onml kjih wvut srqp ~}| {zyx */ | 820 821 /* gfed cba` onml kjih wvut srqp ~}| {zyx */ |
822 0xff, 0xff, 0xff, 0xff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | 822 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
823 | 823 |
824 0xff, 0xff, 0xff, 0xff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 825 0xff, 0xff, 0xff, 0xff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 826 0xff, 0xff, 0xff, 0xff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 827 0xff, 0xff, 0xff, 0xff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | 824 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 825 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 826 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 827 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
828}; 829 830 831static nxt_int_t 832nxt_http_parse_complex_target(nxt_http_request_parse_t *rp) 833{ 834 u_char *p, *u, c, ch, high; 835 enum { --- 334 unchanged lines hidden (view full) --- 1170 key = NXT_HTTP_FIELD_HASH_INIT; 1171 name = &items[i].name; 1172 1173 for (j = 0; j < name->length; j++) { 1174 ch = nxt_lowcase(name->start[j]); 1175 key = nxt_http_field_hash_char(key, ch); 1176 } 1177 | 828}; 829 830 831static nxt_int_t 832nxt_http_parse_complex_target(nxt_http_request_parse_t *rp) 833{ 834 u_char *p, *u, c, ch, high; 835 enum { --- 334 unchanged lines hidden (view full) --- 1170 key = NXT_HTTP_FIELD_HASH_INIT; 1171 name = &items[i].name; 1172 1173 for (j = 0; j < name->length; j++) { 1174 ch = nxt_lowcase(name->start[j]); 1175 key = nxt_http_field_hash_char(key, ch); 1176 } 1177 |
1178 lhq.key_hash = nxt_http_field_hash_end(key) & 0xffff; | 1178 lhq.key_hash = nxt_http_field_hash_end(key) & 0xFFFF; |
1179 lhq.key = *name; 1180 lhq.value = &items[i]; 1181 1182 ret = nxt_lvlhsh_insert(hash, &lhq); 1183 1184 if (nxt_slow_path(ret != NXT_OK)) { 1185 return NXT_ERROR; 1186 } --- 16 unchanged lines hidden (view full) --- 1203 1204 proto = nxt_http_fields_hash_proto; 1205 proto.test = nxt_http_field_hash_collision; 1206 1207 lhq.replace = 0; 1208 lhq.proto = &proto; 1209 lhq.pool = mp; 1210 | 1179 lhq.key = *name; 1180 lhq.value = &items[i]; 1181 1182 ret = nxt_lvlhsh_insert(hash, &lhq); 1183 1184 if (nxt_slow_path(ret != NXT_OK)) { 1185 return NXT_ERROR; 1186 } --- 16 unchanged lines hidden (view full) --- 1203 1204 proto = nxt_http_fields_hash_proto; 1205 proto.test = nxt_http_field_hash_collision; 1206 1207 lhq.replace = 0; 1208 lhq.proto = &proto; 1209 lhq.pool = mp; 1210 |
1211 mask = level ? (1 << NXT_HTTP_FIELD_LVLHSH_SHIFT) - 1 : 0xffff; | 1211 mask = level ? (1 << NXT_HTTP_FIELD_LVLHSH_SHIFT) - 1 : 0xFFFF; |
1212 1213 colls = 0; 1214 1215 for (i = 0; i < count; i++) { 1216 key = NXT_HTTP_FIELD_HASH_INIT; 1217 name = &items[i].name; 1218 1219 for (j = 0; j < name->length; j++) { --- 48 unchanged lines hidden --- | 1212 1213 colls = 0; 1214 1215 for (i = 0; i < count; i++) { 1216 key = NXT_HTTP_FIELD_HASH_INIT; 1217 name = &items[i].name; 1218 1219 for (j = 0; j < name->length; j++) { --- 48 unchanged lines hidden --- |