comparison src/http/ngx_http_parse.c @ 328:26ff8d6b618d NGINX_0_5_34

nginx 0.5.34 *) Change: now the full request line instead of URI only is written to error_log. *) Feature: Cygwin compatibility. Thanks to Vladimir Kutakov. *) Feature: the "merge_slashes" directive. *) Feature: the "gzip_vary" directive. *) Feature: the "server_tokens" directive. *) Feature: the "access_log" directive may be used inside the "limit_except" block. *) Bugfix: if the $server_protocol was used in FastCGI parameters and a request line length was near to the "client_header_buffer_size" directive value, then nginx issued an alert "fastcgi: the request record is too big". *) Bugfix: if a plain text HTTP/0.9 version request was made to HTTPS server, then nginx returned usual response. *) Bugfix: URL double escaping in a redirect of the "msie_refresh" directive; bug appeared in 0.5.28. *) Bugfix: a segmentation fault might occur in worker process if subrequests were used. *) Bugfix: the big responses may be transferred truncated if SSL and gzip were used. *) Bugfix: compatibility with mget. *) Bugfix: nginx did not unescape URI in the "include" SSI command. *) Bugfix: the segmentation fault was occurred on start or while reconfiguration if variable was used in the "charset" or "source_charset" directives. *) Bugfix: nginx returned the 400 response on requests like "GET http://www.domain.com HTTP/1.0". Thanks to James Oakley. *) Bugfix: a segmentation fault occurred in worker process if $date_local and $date_gmt were used outside the ngx_http_ssi_filter_module. *) Bugfix: a segmentation fault might occur in worker process if debug log was enabled. Thanks to Andrei Nigmatulin. *) Bugfix: ngx_http_memcached_module did not set $upstream_response_time. Thanks to Maxim Dounin. *) Bugfix: a worker process may got caught in an endless loop, if the memcached was used.
author Igor Sysoev <http://sysoev.ru>
date Thu, 13 Dec 2007 00:00:00 +0300
parents cba14c1e2a4b
children c60beecc6ab5
comparison
equal deleted inserted replaced
327:cb962a94cd7b 328:26ff8d6b618d
122 sw_http_HTTP, 122 sw_http_HTTP,
123 sw_first_major_digit, 123 sw_first_major_digit,
124 sw_major_digit, 124 sw_major_digit,
125 sw_first_minor_digit, 125 sw_first_minor_digit,
126 sw_minor_digit, 126 sw_minor_digit,
127 sw_spaces_after_digit,
127 sw_almost_done 128 sw_almost_done
128 } state; 129 } state;
129 130
130 state = r->state; 131 state = r->state;
131 132
333 334
334 if ((ch >= '0' && ch <= '9') || ch == '.' || ch == '-') { 335 if ((ch >= '0' && ch <= '9') || ch == '.' || ch == '-') {
335 break; 336 break;
336 } 337 }
337 338
339 r->host_end = p;
340
338 switch (ch) { 341 switch (ch) {
339 case ':': 342 case ':':
340 r->host_end = p;
341 state = sw_port; 343 state = sw_port;
342 break; 344 break;
343 case '/': 345 case '/':
344 r->host_end = p;
345 r->uri_start = p; 346 r->uri_start = p;
346 state = sw_after_slash_in_uri; 347 state = sw_after_slash_in_uri;
347 break; 348 break;
348 default: 349 case ' ':
349 r->host_end = p; 350 /*
351 * use single "/" from request line to preserve pointers,
352 * if request line will be copied to large client buffer
353 */
354 r->uri_start = r->schema_end + 1;
355 r->uri_end = r->schema_end + 2;
356 state = sw_http_09;
357 break;
358 default:
350 return NGX_HTTP_PARSE_INVALID_REQUEST; 359 return NGX_HTTP_PARSE_INVALID_REQUEST;
351 } 360 }
352 break; 361 break;
353 362
354 case sw_port: 363 case sw_port:
360 case '/': 369 case '/':
361 r->port_end = p; 370 r->port_end = p;
362 r->uri_start = p; 371 r->uri_start = p;
363 state = sw_after_slash_in_uri; 372 state = sw_after_slash_in_uri;
364 break; 373 break;
374 case ' ':
375 r->port_end = p;
376 /*
377 * use single "/" from request line to preserve pointers,
378 * if request line will be copied to large client buffer
379 */
380 r->uri_start = r->schema_end + 1;
381 r->uri_end = r->schema_end + 2;
382 state = sw_http_09;
383 break;
365 default: 384 default:
366 return NGX_HTTP_PARSE_INVALID_REQUEST; 385 return NGX_HTTP_PARSE_INVALID_REQUEST;
367 } 386 }
368 break; 387 break;
369 388
616 635
617 if (ch == LF) { 636 if (ch == LF) {
618 goto done; 637 goto done;
619 } 638 }
620 639
640 if (ch == ' ') {
641 state = sw_spaces_after_digit;
642 break;
643 }
644
621 if (ch < '0' || ch > '9') { 645 if (ch < '0' || ch > '9') {
622 return NGX_HTTP_PARSE_INVALID_REQUEST; 646 return NGX_HTTP_PARSE_INVALID_REQUEST;
623 } 647 }
624 648
625 r->http_minor = r->http_minor * 10 + ch - '0'; 649 r->http_minor = r->http_minor * 10 + ch - '0';
650 break;
651
652 case sw_spaces_after_digit:
653 switch (ch) {
654 case ' ':
655 break;
656 case CR:
657 state = sw_almost_done;
658 break;
659 case LF:
660 goto done;
661 default:
662 return NGX_HTTP_PARSE_INVALID_REQUEST;
663 }
626 break; 664 break;
627 665
628 /* end of request line */ 666 /* end of request line */
629 case sw_almost_done: 667 case sw_almost_done:
630 r->request_end = p - 1; 668 r->request_end = p - 1;
888 return NGX_HTTP_PARSE_HEADER_DONE; 926 return NGX_HTTP_PARSE_HEADER_DONE;
889 } 927 }
890 928
891 929
892 ngx_int_t 930 ngx_int_t
893 ngx_http_parse_complex_uri(ngx_http_request_t *r) 931 ngx_http_parse_complex_uri(ngx_http_request_t *r, ngx_uint_t merge_slashes)
894 { 932 {
895 u_char c, ch, decoded, *p, *u; 933 u_char c, ch, decoded, *p, *u;
896 enum { 934 enum {
897 sw_usual = 0, 935 sw_usual = 0,
898 sw_slash, 936 sw_slash,
996 } 1034 }
997 1035
998 switch(ch) { 1036 switch(ch) {
999 #if (NGX_WIN32) 1037 #if (NGX_WIN32)
1000 case '\\': 1038 case '\\':
1039 break;
1001 #endif 1040 #endif
1002 case '/': 1041 case '/':
1042 if (merge_slashes) {
1043 *u++ = ch;
1044 }
1003 break; 1045 break;
1004 case '.': 1046 case '.':
1005 state = sw_dot; 1047 state = sw_dot;
1006 *u++ = ch; 1048 *u++ = ch;
1007 break; 1049 break;