Deleted
Added
nxt_http_parse.c (1213:f334dd97291d) | nxt_http_parse.c (1214:c3666b232602) |
---|---|
1 2/* 3 * Copyright (C) NGINX, Inc. 4 * Copyright (C) Valentin V. Bartenev 5 */ 6 7#include <nxt_main.h> 8 --- 148 unchanged lines hidden (view full) --- 157 return rc; 158} 159 160 161static nxt_int_t 162nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos, 163 u_char *end) 164{ | 1 2/* 3 * Copyright (C) NGINX, Inc. 4 * Copyright (C) Valentin V. Bartenev 5 */ 6 7#include <nxt_main.h> 8 --- 148 unchanged lines hidden (view full) --- 157 return rc; 158} 159 160 161static nxt_int_t 162nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos, 163 u_char *end) 164{ |
165 u_char *p, ch, *after_slash, *exten, *args; | 165 u_char *p, ch, *after_slash, *args; |
166 nxt_int_t rc; 167 nxt_bool_t rest; 168 nxt_http_ver_t ver; 169 nxt_http_target_traps_e trap; 170 171 static const nxt_http_ver_t http11 = { "HTTP/1.1" }; 172 static const nxt_http_ver_t http10 = { "HTTP/1.0" }; 173 --- 76 unchanged lines hidden (view full) --- 250 if (nxt_slow_path(rc != NXT_OK)) { 251 return rc; 252 } 253 } 254 255 rp->target_start = p; 256 257 after_slash = p + 1; | 166 nxt_int_t rc; 167 nxt_bool_t rest; 168 nxt_http_ver_t ver; 169 nxt_http_target_traps_e trap; 170 171 static const nxt_http_ver_t http11 = { "HTTP/1.1" }; 172 static const nxt_http_ver_t http10 = { "HTTP/1.0" }; 173 --- 76 unchanged lines hidden (view full) --- 250 if (nxt_slow_path(rc != NXT_OK)) { 251 return rc; 252 } 253 } 254 255 rp->target_start = p; 256 257 after_slash = p + 1; |
258 exten = NULL; | |
259 args = NULL; 260 rest = 0; 261 262continue_target: 263 264 for ( ;; ) { 265 p++; 266 267 trap = nxt_http_parse_target(&p, end); 268 269 switch (trap) { 270 case NXT_HTTP_TARGET_SLASH: 271 if (nxt_slow_path(after_slash == p)) { 272 rp->complex_target = 1; 273 goto rest_of_target; 274 } 275 276 after_slash = p + 1; | 258 args = NULL; 259 rest = 0; 260 261continue_target: 262 263 for ( ;; ) { 264 p++; 265 266 trap = nxt_http_parse_target(&p, end); 267 268 switch (trap) { 269 case NXT_HTTP_TARGET_SLASH: 270 if (nxt_slow_path(after_slash == p)) { 271 rp->complex_target = 1; 272 goto rest_of_target; 273 } 274 275 after_slash = p + 1; |
277 exten = NULL; | |
278 continue; 279 280 case NXT_HTTP_TARGET_DOT: 281 if (nxt_slow_path(after_slash == p)) { 282 rp->complex_target = 1; 283 goto rest_of_target; 284 } 285 | 276 continue; 277 278 case NXT_HTTP_TARGET_DOT: 279 if (nxt_slow_path(after_slash == p)) { 280 rp->complex_target = 1; 281 goto rest_of_target; 282 } 283 |
286 exten = p + 1; | |
287 continue; 288 289 case NXT_HTTP_TARGET_ARGS_MARK: 290 args = p + 1; 291 goto rest_of_target; 292 293 case NXT_HTTP_TARGET_SPACE: 294 rp->target_end = p; --- 159 unchanged lines hidden (view full) --- 454 455 rp->args.length = rp->target_end - args; 456 rp->args.start = args; 457 458 } else { 459 rp->path.length = rp->target_end - rp->target_start; 460 } 461 | 284 continue; 285 286 case NXT_HTTP_TARGET_ARGS_MARK: 287 args = p + 1; 288 goto rest_of_target; 289 290 case NXT_HTTP_TARGET_SPACE: 291 rp->target_end = p; --- 159 unchanged lines hidden (view full) --- 451 452 rp->args.length = rp->target_end - args; 453 rp->args.start = args; 454 455 } else { 456 rp->path.length = rp->target_end - rp->target_start; 457 } 458 |
462 if (exten != NULL) { 463 rp->exten.length = (rp->path.start + rp->path.length) - exten; 464 rp->exten.start = exten; 465 } 466 | |
467 return nxt_http_parse_field_name(rp, pos, end); 468 } 469 470 if (nxt_memcmp(ver.s.prefix, "HTTP/", 5) == 0 471 && ver.s.major >= '0' && ver.s.major <= '9' 472 && ver.s.point == '.' 473 && ver.s.minor >= '0' && ver.s.minor <= '9') 474 { --- 366 unchanged lines hidden (view full) --- 841 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 842 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 843}; 844 845 846static nxt_int_t 847nxt_http_parse_complex_target(nxt_http_request_parse_t *rp) 848{ | 459 return nxt_http_parse_field_name(rp, pos, end); 460 } 461 462 if (nxt_memcmp(ver.s.prefix, "HTTP/", 5) == 0 463 && ver.s.major >= '0' && ver.s.major <= '9' 464 && ver.s.point == '.' 465 && ver.s.minor >= '0' && ver.s.minor <= '9') 466 { --- 366 unchanged lines hidden (view full) --- 833 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 834 0xFF, 0xFF, 0xFF, 0xFF, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 835}; 836 837 838static nxt_int_t 839nxt_http_parse_complex_target(nxt_http_request_parse_t *rp) 840{ |
849 u_char *p, *u, c, ch, high, *exten, *args; | 841 u_char *p, *u, c, ch, high, *args; |
850 851 enum { 852 sw_normal = 0, 853 sw_slash, 854 sw_dot, 855 sw_dot_dot, 856 sw_quoted, 857 sw_quoted_second, --- 9 unchanged lines hidden (view full) --- 867 if (nxt_slow_path(u == NULL)) { 868 return NXT_ERROR; 869 } 870 871 rp->path.length = 0; 872 rp->path.start = u; 873 874 high = '\0'; | 842 843 enum { 844 sw_normal = 0, 845 sw_slash, 846 sw_dot, 847 sw_dot_dot, 848 sw_quoted, 849 sw_quoted_second, --- 9 unchanged lines hidden (view full) --- 859 if (nxt_slow_path(u == NULL)) { 860 return NXT_ERROR; 861 } 862 863 rp->path.length = 0; 864 rp->path.start = u; 865 866 high = '\0'; |
875 exten = NULL; | |
876 args = NULL; 877 878 while (p < rp->target_end) { 879 880 ch = *p++; 881 882 again: 883 884 switch (state) { 885 886 case sw_normal: 887 888 if (nxt_http_is_normal(ch)) { 889 *u++ = ch; 890 continue; 891 } 892 893 switch (ch) { 894 case '/': | 867 args = NULL; 868 869 while (p < rp->target_end) { 870 871 ch = *p++; 872 873 again: 874 875 switch (state) { 876 877 case sw_normal: 878 879 if (nxt_http_is_normal(ch)) { 880 *u++ = ch; 881 continue; 882 } 883 884 switch (ch) { 885 case '/': |
895 exten = NULL; | |
896 state = sw_slash; 897 *u++ = ch; 898 continue; 899 case '%': 900 saved_state = state; 901 state = sw_quoted; 902 continue; 903 case '?': 904 args = p; 905 goto args; 906 case '#': 907 goto done; | 886 state = sw_slash; 887 *u++ = ch; 888 continue; 889 case '%': 890 saved_state = state; 891 state = sw_quoted; 892 continue; 893 case '?': 894 args = p; 895 goto args; 896 case '#': 897 goto done; |
908 case '.': 909 exten = u + 1; 910 *u++ = ch; 911 continue; | |
912 default: 913 *u++ = ch; 914 continue; 915 } 916 917 break; 918 919 case sw_slash: --- 213 unchanged lines hidden (view full) --- 1133 rp->args.length = p - args; 1134 rp->args.start = args; 1135 } 1136 1137done: 1138 1139 rp->path.length = u - rp->path.start; 1140 | 898 default: 899 *u++ = ch; 900 continue; 901 } 902 903 break; 904 905 case sw_slash: --- 213 unchanged lines hidden (view full) --- 1119 rp->args.length = p - args; 1120 rp->args.start = args; 1121 } 1122 1123done: 1124 1125 rp->path.length = u - rp->path.start; 1126 |
1141 if (exten) { 1142 rp->exten.length = u - exten; 1143 rp->exten.start = exten; 1144 } 1145 | |
1146 return NXT_OK; 1147} 1148 1149 1150const nxt_lvlhsh_proto_t nxt_http_fields_hash_proto nxt_aligned(64) = { 1151 NXT_LVLHSH_BUCKET_SIZE(64), 1152 { NXT_HTTP_FIELD_LVLHSH_SHIFT, 0, 0, 0, 0, 0, 0, 0 }, 1153 nxt_http_field_hash_test, --- 140 unchanged lines hidden --- | 1127 return NXT_OK; 1128} 1129 1130 1131const nxt_lvlhsh_proto_t nxt_http_fields_hash_proto nxt_aligned(64) = { 1132 NXT_LVLHSH_BUCKET_SIZE(64), 1133 { NXT_HTTP_FIELD_LVLHSH_SHIFT, 0, 0, 0, 0, 0, 0, 0 }, 1134 nxt_http_field_hash_test, --- 140 unchanged lines hidden --- |