comparison src/http/modules/ngx_http_fastcgi_handler.c @ 36:a39d1b793287 NGINX_0_1_18

nginx 0.1.18 *) Workaround: the default values of the devpoll_events and the devpoll_changes directives changed from 512 to 32 to be compatible with Solaris 10. *) Bugfix: the proxy_set_x_var and fastcgi_set_var directives were not inherited. *) Bugfix: in the redirect rewrite directive the arguments were concatenated with URI by the "&" rather than the "?". *) Bugfix: the lines without trailing ";" in the file being included by the ngx_http_geo_module were silently ignored. *) Feature: the ngx_http_stub_status_module. *) Bugfix: the unknown log format in the access_log directive caused the segmentation fault. *) Feature: the new "document_root" parameter of the fastcgi_params directive. *) Feature: the fastcgi_redirect_errors directive. *) Feature: the new "break" modifier of the "rewrite" directive allows to stop the rewrite/location cycle and sets the current configuration to the request.
author Igor Sysoev <http://sysoev.ru>
date Wed, 09 Feb 2005 00:00:00 +0300
parents aab2ea7c0458
children bc4fc02c96a3
comparison
equal deleted inserted replaced
35:ef53675fe4a6 36:a39d1b793287
18 ngx_uint_t params; 18 ngx_uint_t params;
19 19
20 ngx_str_t root; 20 ngx_str_t root;
21 ngx_str_t index; 21 ngx_str_t index;
22 22
23 ngx_array_t vars; 23 ngx_array_t *vars;
24 24
25 ngx_str_t *location; 25 ngx_str_t *location;
26 } ngx_http_fastcgi_loc_conf_t; 26 } ngx_http_fastcgi_loc_conf_t;
27 27
28 28
82 #define NGX_HTTP_FASTCGI_SERVER_PROTOCOL 0x0100 82 #define NGX_HTTP_FASTCGI_SERVER_PROTOCOL 0x0100
83 #define NGX_HTTP_FASTCGI_SERVER_SOFTWARE 0x0200 83 #define NGX_HTTP_FASTCGI_SERVER_SOFTWARE 0x0200
84 #define NGX_HTTP_FASTCGI_GATEWAY_INTERFACE 0x0400 84 #define NGX_HTTP_FASTCGI_GATEWAY_INTERFACE 0x0400
85 #define NGX_HTTP_FASTCGI_REQUEST_URI 0x0800 85 #define NGX_HTTP_FASTCGI_REQUEST_URI 0x0800
86 #define NGX_HTTP_FASTCGI_REDIRECT_STATUS 0x1000 86 #define NGX_HTTP_FASTCGI_REDIRECT_STATUS 0x1000
87 #define NGX_HTTP_FASTCGI_DOCUMENT_ROOT 0x2000
87 88
88 89
89 #define NGX_HTTP_FASTCGI_RESPONDER 1 90 #define NGX_HTTP_FASTCGI_RESPONDER 1
90 91
91 #define NGX_HTTP_FASTCGI_BEGIN_REQUEST 1 92 #define NGX_HTTP_FASTCGI_BEGIN_REQUEST 1
121 static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r); 122 static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r);
122 static ngx_int_t ngx_http_fastcgi_reinit_request(ngx_http_request_t *r); 123 static ngx_int_t ngx_http_fastcgi_reinit_request(ngx_http_request_t *r);
123 static ngx_int_t ngx_http_fastcgi_process_header(ngx_http_request_t *r); 124 static ngx_int_t ngx_http_fastcgi_process_header(ngx_http_request_t *r);
124 static ngx_int_t ngx_http_fastcgi_send_header(ngx_http_request_t *r); 125 static ngx_int_t ngx_http_fastcgi_send_header(ngx_http_request_t *r);
125 static ngx_int_t ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, 126 static ngx_int_t ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p,
126 ngx_buf_t *buf); 127 ngx_buf_t *buf);
127 static ngx_int_t ngx_http_fastcgi_process_record(ngx_http_request_t *r, 128 static ngx_int_t ngx_http_fastcgi_process_record(ngx_http_request_t *r,
128 ngx_http_fastcgi_ctx_t *f); 129 ngx_http_fastcgi_ctx_t *f);
129 static void ngx_http_fastcgi_abort_request(ngx_http_request_t *r); 130 static void ngx_http_fastcgi_abort_request(ngx_http_request_t *r);
130 static void ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, 131 static void ngx_http_fastcgi_finalize_request(ngx_http_request_t *r,
131 ngx_int_t rc); 132 ngx_int_t rc);
132 133
133 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, 134 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
134 void *conf); 135 void *conf);
135 static char *ngx_http_fastcgi_set_var(ngx_conf_t *cf, ngx_command_t *cmd, 136 static char *ngx_http_fastcgi_set_var(ngx_conf_t *cf, ngx_command_t *cmd,
136 void *conf); 137 void *conf);
137 static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, 138 static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post,
138 void *data); 139 void *data);
139 static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf); 140 static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf);
140 static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, 141 static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf,
141 void *parent, void *child); 142 void *parent, void *child);
142 143
143 144
144 static ngx_str_t ngx_http_fastcgi_methods[] = { 145 static ngx_str_t ngx_http_fastcgi_methods[] = {
145 ngx_string("GET"), 146 ngx_string("GET"),
146 ngx_string("HEAD"), 147 ngx_string("HEAD"),
153 154
154 static ngx_http_header_t ngx_http_fastcgi_headers_in[] = { 155 static ngx_http_header_t ngx_http_fastcgi_headers_in[] = {
155 { ngx_string("Status"), offsetof(ngx_http_fastcgi_headers_in_t, status) }, 156 { ngx_string("Status"), offsetof(ngx_http_fastcgi_headers_in_t, status) },
156 157
157 { ngx_string("Content-Type"), 158 { ngx_string("Content-Type"),
158 offsetof(ngx_http_fastcgi_headers_in_t, content_type) }, 159 offsetof(ngx_http_fastcgi_headers_in_t, content_type) },
159 160
160 { ngx_string("Content-Length"), 161 { ngx_string("Content-Length"),
161 offsetof(ngx_http_fastcgi_headers_in_t, content_length) }, 162 offsetof(ngx_http_fastcgi_headers_in_t, content_length) },
162 163
163 { ngx_string("X-Powered-By"), 164 { ngx_string("X-Powered-By"),
164 offsetof(ngx_http_fastcgi_headers_in_t, x_powered_by) }, 165 offsetof(ngx_http_fastcgi_headers_in_t, x_powered_by) },
165 166
166 #if (NGX_HTTP_GZIP) 167 #if (NGX_HTTP_GZIP)
167 { ngx_string("Content-Encoding"), 168 { ngx_string("Content-Encoding"),
168 offsetof(ngx_http_fastcgi_headers_in_t, content_encoding) }, 169 offsetof(ngx_http_fastcgi_headers_in_t, content_encoding) },
169 #endif 170 #endif
170 171
171 { ngx_null_string, 0 } 172 { ngx_null_string, 0 }
172 }; 173 };
173 174
174 175
175 static ngx_conf_post_t ngx_http_fastcgi_lowat_post = 176 static ngx_conf_post_t ngx_http_fastcgi_lowat_post =
176 { ngx_http_fastcgi_lowat_check } ; 177 { ngx_http_fastcgi_lowat_check };
177 178
178 static ngx_conf_bitmask_t ngx_http_fastcgi_next_upstream_masks[] = { 179 static ngx_conf_bitmask_t ngx_http_fastcgi_next_upstream_masks[] = {
179 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, 180 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR },
180 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, 181 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT },
181 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, 182 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER },
196 { ngx_string("server_software"), NGX_HTTP_FASTCGI_SERVER_SOFTWARE }, 197 { ngx_string("server_software"), NGX_HTTP_FASTCGI_SERVER_SOFTWARE },
197 { ngx_string("gateway_interface"), NGX_HTTP_FASTCGI_GATEWAY_INTERFACE }, 198 { ngx_string("gateway_interface"), NGX_HTTP_FASTCGI_GATEWAY_INTERFACE },
198 199
199 { ngx_string("redirect_status"), NGX_HTTP_FASTCGI_REDIRECT_STATUS }, 200 { ngx_string("redirect_status"), NGX_HTTP_FASTCGI_REDIRECT_STATUS },
200 { ngx_string("request_uri"), NGX_HTTP_FASTCGI_REQUEST_URI }, 201 { ngx_string("request_uri"), NGX_HTTP_FASTCGI_REQUEST_URI },
202 { ngx_string("document_root"), NGX_HTTP_FASTCGI_DOCUMENT_ROOT },
201 203
202 { ngx_null_string, 0 } 204 { ngx_null_string, 0 }
203 }; 205 };
204 206
205 207
250 { ngx_string("fastcgi_header_buffer_size"), 252 { ngx_string("fastcgi_header_buffer_size"),
251 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 253 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
252 ngx_conf_set_size_slot, 254 ngx_conf_set_size_slot,
253 NGX_HTTP_LOC_CONF_OFFSET, 255 NGX_HTTP_LOC_CONF_OFFSET,
254 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.header_buffer_size), 256 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.header_buffer_size),
257 NULL },
258
259 { ngx_string("fastcgi_redirect_errors"),
260 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
261 ngx_conf_set_flag_slot,
262 NGX_HTTP_LOC_CONF_OFFSET,
263 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.redirect_errors),
255 NULL }, 264 NULL },
256 265
257 { ngx_string("fastcgi_x_powered_by"), 266 { ngx_string("fastcgi_x_powered_by"),
258 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, 267 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
259 ngx_conf_set_flag_slot, 268 ngx_conf_set_flag_slot,
350 NULL, /* init module */ 359 NULL, /* init module */
351 NULL /* init process */ 360 NULL /* init process */
352 }; 361 };
353 362
354 363
355 static ngx_int_t ngx_http_fastcgi_handler(ngx_http_request_t *r) 364 static ngx_int_t
365 ngx_http_fastcgi_handler(ngx_http_request_t *r)
356 { 366 {
357 ngx_int_t rc; 367 ngx_int_t rc;
358 ngx_http_upstream_t *u; 368 ngx_http_upstream_t *u;
359 ngx_http_fastcgi_loc_conf_t *flcf; 369 ngx_http_fastcgi_loc_conf_t *flcf;
360 370
406 416
407 return NGX_DONE; 417 return NGX_DONE;
408 } 418 }
409 419
410 420
411 static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r) 421 static ngx_int_t
422 ngx_http_fastcgi_create_request(ngx_http_request_t *r)
412 { 423 {
413 u_char ch, *pos, addr_text[INET_ADDRSTRLEN]; 424 u_char ch, *pos, addr_text[INET_ADDRSTRLEN];
414 size_t size, len, index, padding, addr_len; 425 size_t size, len, index, padding, addr_len;
415 off_t file_pos; 426 off_t file_pos;
416 ngx_buf_t *b; 427 ngx_buf_t *b;
420 ngx_list_part_t *part; 431 ngx_list_part_t *part;
421 ngx_table_elt_t *header; 432 ngx_table_elt_t *header;
422 struct sockaddr_in sin; 433 struct sockaddr_in sin;
423 ngx_http_variable_t *var; 434 ngx_http_variable_t *var;
424 ngx_http_variable_value_t *value; 435 ngx_http_variable_value_t *value;
436 ngx_http_core_loc_conf_t *clcf;
425 ngx_http_core_main_conf_t *cmcf; 437 ngx_http_core_main_conf_t *cmcf;
426 ngx_http_fastcgi_header_t *h; 438 ngx_http_fastcgi_header_t *h;
427 ngx_http_fastcgi_loc_conf_t *flcf; 439 ngx_http_fastcgi_loc_conf_t *flcf;
428 ngx_http_fastcgi_begin_request_t *br; 440 ngx_http_fastcgi_begin_request_t *br;
429 441
447 addr_len = ngx_inet_ntop(r->connection->listening->family, &r->in_addr, 459 addr_len = ngx_inet_ntop(r->connection->listening->family, &r->in_addr,
448 addr_text, INET_ADDRSTRLEN); 460 addr_text, INET_ADDRSTRLEN);
449 if (addr_len == 0) { 461 if (addr_len == 0) {
450 return NGX_ERROR; 462 return NGX_ERROR;
451 } 463 }
464
465 #if (NGX_SUPPRESS_WARN)
466 clcf = NULL;
467 var = NULL;
468 vindex = NULL;
469 #endif
452 470
453 471
454 if (r->upstream->method) { 472 if (r->upstream->method) {
455 len = 1 + 1 + sizeof("REQUEST_METHOD") - 1 473 len = 1 + 1 + sizeof("REQUEST_METHOD") - 1
456 + ngx_http_fastcgi_methods[r->upstream->method - 1].len; 474 + ngx_http_fastcgi_methods[r->upstream->method - 1].len;
494 if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) { 512 if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
495 len += 1 + ((r->unparsed_uri.len > 127) ? 4 : 1) 513 len += 1 + ((r->unparsed_uri.len > 127) ? 4 : 1)
496 + sizeof("REQUEST_URI") - 1 + r->unparsed_uri.len; 514 + sizeof("REQUEST_URI") - 1 + r->unparsed_uri.len;
497 } 515 }
498 516
517 if (flcf->params & NGX_HTTP_FASTCGI_DOCUMENT_ROOT) {
518 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
519 len += 1 + ((clcf->root.len > 127) ? 4 : 1)
520 + sizeof("DOCUMENT_ROOT") - 1 + clcf->root.len;
521 }
522
499 if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) { 523 if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) {
500 len += 1 + ((r->uri.len + index > 127) ? 4 : 1) 524 len += 1 + ((r->uri.len + index > 127) ? 4 : 1)
501 + sizeof("SCRIPT_NAME") - 1 + r->uri.len + index ; 525 + sizeof("SCRIPT_NAME") - 1 + r->uri.len + index ;
502 } 526 }
503 527
531 if (flcf->params & NGX_HTTP_FASTCGI_GATEWAY_INTERFACE) { 555 if (flcf->params & NGX_HTTP_FASTCGI_GATEWAY_INTERFACE) {
532 len += 1 + 1 + sizeof("GATEWAY_INTERFACE") - 1 + sizeof("CGI/1.1") - 1; 556 len += 1 + 1 + sizeof("GATEWAY_INTERFACE") - 1 + sizeof("CGI/1.1") - 1;
533 } 557 }
534 558
535 559
536 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); 560 if (flcf->vars) {
537 561 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
538 var = cmcf->variables.elts; 562
539 vindex = flcf->vars.elts; 563 var = cmcf->variables.elts;
540 564 vindex = flcf->vars->elts;
541 for (i = 0; i < flcf->vars.nelts; i++) { 565
542 566 for (i = 0; i < flcf->vars->nelts; i++) {
543 if (!(value = ngx_http_get_variable(r, vindex[i]))) { 567
544 continue; 568 if (!(value = ngx_http_get_variable(r, vindex[i]))) {
545 } 569 continue;
546 570 }
547 if (value->text.len) { 571
548 len += 1 + 1 + var[vindex[i]].name.len + value->text.len; 572 if (value->text.len) {
573 len += 1 + 1 + var[vindex[i]].name.len + value->text.len;
574 }
549 } 575 }
550 } 576 }
551 577
552 578
553 part = &r->headers_in.headers.part; 579 part = &r->headers_in.headers.part;
783 b->last = ngx_cpymem(b->last, "REQUEST_URI", sizeof("REQUEST_URI") - 1); 809 b->last = ngx_cpymem(b->last, "REQUEST_URI", sizeof("REQUEST_URI") - 1);
784 b->last = ngx_cpymem(b->last, r->unparsed_uri.data, len); 810 b->last = ngx_cpymem(b->last, r->unparsed_uri.data, len);
785 } 811 }
786 812
787 813
814 if (flcf->params & NGX_HTTP_FASTCGI_DOCUMENT_ROOT) {
815 *b->last++ = sizeof("DOCUMENT_ROOT") - 1;
816
817 len = clcf->root.len;
818 if (len > 127) {
819 *b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80);
820 *b->last++ = (u_char) ((len >> 16) & 0xff);
821 *b->last++ = (u_char) ((len >> 8) & 0xff);
822 *b->last++ = (u_char) (len & 0xff);
823
824 } else {
825 *b->last++ = (u_char) len;
826 }
827
828 b->last = ngx_cpymem(b->last, "DOCUMENT_ROOT",
829 sizeof("DOCUMENT_ROOT") - 1);
830 b->last = ngx_cpymem(b->last, clcf->root.data, len);
831 }
832
833
788 if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) { 834 if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) {
789 *b->last++ = sizeof("SCRIPT_NAME") - 1; 835 *b->last++ = sizeof("SCRIPT_NAME") - 1;
790 836
791 len = r->uri.len + index; 837 len = r->uri.len + index;
792 if (len > 127) { 838 if (len > 127) {
880 sizeof("GATEWAY_INTERFACE") - 1); 926 sizeof("GATEWAY_INTERFACE") - 1);
881 b->last = ngx_cpymem(b->last, "CGI/1.1", sizeof("CGI/1.1") - 1); 927 b->last = ngx_cpymem(b->last, "CGI/1.1", sizeof("CGI/1.1") - 1);
882 } 928 }
883 929
884 930
885 for (i = 0; i < flcf->vars.nelts; i++) { 931 if (flcf->vars) {
886 932 for (i = 0; i < flcf->vars->nelts; i++) {
887 if (!(value = ngx_http_get_variable(r, vindex[i]))) { 933
888 continue; 934 if (!(value = ngx_http_get_variable(r, vindex[i]))) {
889 } 935 continue;
890 936 }
891 if (value->text.len == 0) { 937
892 continue; 938 if (value->text.len == 0) {
893 } 939 continue;
894 940 }
895 *b->last++ = (u_char) var[vindex[i]].name.len; 941
896 *b->last++ = (u_char) value->text.len; 942 *b->last++ = (u_char) var[vindex[i]].name.len;
897 943 *b->last++ = (u_char) value->text.len;
898 b->last = ngx_cpymem(b->last, var[vindex[i]].name.data, 944
899 var[vindex[i]].name.len); 945 b->last = ngx_cpymem(b->last, var[vindex[i]].name.data,
900 946 var[vindex[i]].name.len);
901 b->last = ngx_cpymem(b->last, value->text.data, value->text.len); 947
948 b->last = ngx_cpymem(b->last, value->text.data, value->text.len);
949 }
902 } 950 }
903 951
904 952
905 part = &r->headers_in.headers.part; 953 part = &r->headers_in.headers.part;
906 header = part->elts; 954 header = part->elts;
1089 1137
1090 return NGX_OK; 1138 return NGX_OK;
1091 } 1139 }
1092 1140
1093 1141
1094 static ngx_int_t ngx_http_fastcgi_reinit_request(ngx_http_request_t *r) 1142 static ngx_int_t
1143 ngx_http_fastcgi_reinit_request(ngx_http_request_t *r)
1095 { 1144 {
1096 ngx_http_fastcgi_ctx_t *f; 1145 ngx_http_fastcgi_ctx_t *f;
1097 1146
1098 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); 1147 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
1099 1148
1355 return NGX_OK; 1404 return NGX_OK;
1356 } 1405 }
1357 } 1406 }
1358 1407
1359 1408
1360 static ngx_int_t ngx_http_fastcgi_send_header(ngx_http_request_t *r) 1409 static ngx_int_t
1410 ngx_http_fastcgi_send_header(ngx_http_request_t *r)
1361 { 1411 {
1362 ngx_uint_t i; 1412 ngx_uint_t i;
1363 ngx_list_part_t *part; 1413 ngx_list_part_t *part;
1364 ngx_table_elt_t *ho, *h; 1414 ngx_table_elt_t *ho, *h;
1365 ngx_http_fastcgi_ctx_t *f; 1415 ngx_http_fastcgi_ctx_t *f;
1431 1481
1432 return ngx_http_send_header(r); 1482 return ngx_http_send_header(r);
1433 } 1483 }
1434 1484
1435 1485
1436 static ngx_int_t ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, 1486 static ngx_int_t
1437 ngx_buf_t *buf) 1487 ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
1438 { 1488 {
1439 ngx_int_t rc; 1489 ngx_int_t rc;
1440 ngx_buf_t *b, **prev; 1490 ngx_buf_t *b, **prev;
1441 ngx_str_t line; 1491 ngx_str_t line;
1442 ngx_chain_t *cl; 1492 ngx_chain_t *cl;
1635 1685
1636 return NGX_OK; 1686 return NGX_OK;
1637 } 1687 }
1638 1688
1639 1689
1640 static ngx_int_t ngx_http_fastcgi_process_record(ngx_http_request_t *r, 1690 static ngx_int_t
1641 ngx_http_fastcgi_ctx_t *f) 1691 ngx_http_fastcgi_process_record(ngx_http_request_t *r,
1692 ngx_http_fastcgi_ctx_t *f)
1642 { 1693 {
1643 u_char ch, *p; 1694 u_char ch, *p;
1644 ngx_http_upstream_t *u; 1695 ngx_http_upstream_t *u;
1645 ngx_http_fastcgi_state_e state; 1696 ngx_http_fastcgi_state_e state;
1646 1697
1744 1795
1745 return NGX_AGAIN; 1796 return NGX_AGAIN;
1746 } 1797 }
1747 1798
1748 1799
1749 static void ngx_http_fastcgi_abort_request(ngx_http_request_t *r) 1800 static void
1801 ngx_http_fastcgi_abort_request(ngx_http_request_t *r)
1750 { 1802 {
1751 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1803 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1752 "abort http fastcgi request"); 1804 "abort http fastcgi request");
1753 1805
1754 return; 1806 return;
1755 } 1807 }
1756 1808
1757 1809
1758 static void ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, 1810 static void
1759 ngx_int_t rc) 1811 ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
1760 { 1812 {
1761 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1813 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1762 "finalize http fastcgi request"); 1814 "finalize http fastcgi request");
1763 1815
1764 return; 1816 return;
1765 } 1817 }
1766 1818
1767 1819
1768 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, 1820 static char *
1769 void *conf) 1821 ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1770 { 1822 {
1771 ngx_http_fastcgi_loc_conf_t *lcf = conf; 1823 ngx_http_fastcgi_loc_conf_t *lcf = conf;
1772 1824
1773 ngx_str_t *value; 1825 ngx_str_t *value;
1774 ngx_inet_upstream_t inet_upstream; 1826 ngx_inet_upstream_t inet_upstream;
1827 1879
1828 return NGX_CONF_OK; 1880 return NGX_CONF_OK;
1829 } 1881 }
1830 1882
1831 1883
1832 static char *ngx_http_fastcgi_set_var(ngx_conf_t *cf, ngx_command_t *cmd, 1884 static char *
1833 void *conf) 1885 ngx_http_fastcgi_set_var(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1834 { 1886 {
1835 ngx_http_fastcgi_loc_conf_t *lcf = conf; 1887 ngx_http_fastcgi_loc_conf_t *lcf = conf;
1836 1888
1837 ngx_uint_t i, *index; 1889 ngx_uint_t i, *index;
1838 ngx_str_t *value; 1890 ngx_str_t *value;
1839 ngx_http_variable_t *var; 1891 ngx_http_variable_t *var;
1840 ngx_http_core_main_conf_t *cmcf; 1892 ngx_http_core_main_conf_t *cmcf;
1841 1893
1842 if (lcf->vars.elts == NULL) { 1894 if (lcf->vars == NULL) {
1843 if (ngx_array_init(&lcf->vars, cf->pool, 4, 1895 lcf->vars = ngx_array_create(cf->pool, 4,
1844 sizeof(ngx_http_variable_t *)) == NGX_ERROR) 1896 sizeof(ngx_http_variable_t *));
1845 { 1897 if (lcf->vars == NULL) {
1846 return NGX_CONF_ERROR; 1898 return NGX_CONF_ERROR;
1847 } 1899 }
1848 } 1900 }
1849 1901
1850 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); 1902 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
1853 1905
1854 var = cmcf->variables.elts; 1906 var = cmcf->variables.elts;
1855 for (i = 0; i < cmcf->variables.nelts; i++) { 1907 for (i = 0; i < cmcf->variables.nelts; i++) {
1856 if (ngx_strcasecmp(var[i].name.data, value[1].data) == 0) { 1908 if (ngx_strcasecmp(var[i].name.data, value[1].data) == 0) {
1857 1909
1858 if (!(index = ngx_array_push(&lcf->vars))) { 1910 if (!(index = ngx_array_push(lcf->vars))) {
1859 return NGX_CONF_ERROR; 1911 return NGX_CONF_ERROR;
1860 } 1912 }
1861 1913
1862 *index = var[i].index; 1914 *index = var[i].index;
1863 return NGX_CONF_OK; 1915 return NGX_CONF_OK;
1868 "unknown variable name \"%V\"", &value[1]); 1920 "unknown variable name \"%V\"", &value[1]);
1869 return NGX_CONF_ERROR; 1921 return NGX_CONF_ERROR;
1870 } 1922 }
1871 1923
1872 1924
1873 static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, 1925 static char *
1874 void *data) 1926 ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data)
1875 { 1927 {
1876 #if (NGX_FREEBSD) 1928 #if (NGX_FREEBSD)
1877 ssize_t *np = data; 1929 ssize_t *np = data;
1878 1930
1879 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { 1931 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) {
1897 1949
1898 return NGX_CONF_OK; 1950 return NGX_CONF_OK;
1899 } 1951 }
1900 1952
1901 1953
1902 static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf) 1954 static void *
1955 ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf)
1903 { 1956 {
1904 ngx_http_fastcgi_loc_conf_t *conf; 1957 ngx_http_fastcgi_loc_conf_t *conf;
1905 1958
1906 if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t)))) { 1959 if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t)))) {
1907 return NGX_CONF_ERROR; 1960 return NGX_CONF_ERROR;
1931 conf->upstream.busy_buffers_size = NGX_CONF_UNSET_SIZE; 1984 conf->upstream.busy_buffers_size = NGX_CONF_UNSET_SIZE;
1932 1985
1933 conf->upstream.max_temp_file_size = NGX_CONF_UNSET_SIZE; 1986 conf->upstream.max_temp_file_size = NGX_CONF_UNSET_SIZE;
1934 conf->upstream.temp_file_write_size = NGX_CONF_UNSET_SIZE; 1987 conf->upstream.temp_file_write_size = NGX_CONF_UNSET_SIZE;
1935 1988
1989 conf->upstream.redirect_errors = NGX_CONF_UNSET;
1936 conf->upstream.x_powered_by = NGX_CONF_UNSET; 1990 conf->upstream.x_powered_by = NGX_CONF_UNSET;
1937 1991
1938 /* "fastcgi_cyclic_temp_file" is disabled */ 1992 /* "fastcgi_cyclic_temp_file" is disabled */
1939 conf->upstream.cyclic_temp_file = 0; 1993 conf->upstream.cyclic_temp_file = 0;
1940 1994
1941 return conf; 1995 return conf;
1942 } 1996 }
1943 1997
1944 1998
1945 static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, 1999 static char *
1946 void *parent, void *child) 2000 ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1947 { 2001 {
1948 ngx_http_fastcgi_loc_conf_t *prev = parent; 2002 ngx_http_fastcgi_loc_conf_t *prev = parent;
1949 ngx_http_fastcgi_loc_conf_t *conf = child; 2003 ngx_http_fastcgi_loc_conf_t *conf = child;
1950 2004
1951 size_t size; 2005 size_t size;
1957 ngx_conf_merge_size_value(conf->upstream.send_lowat, 2011 ngx_conf_merge_size_value(conf->upstream.send_lowat,
1958 prev->upstream.send_lowat, 0); 2012 prev->upstream.send_lowat, 0);
1959 2013
1960 ngx_conf_merge_msec_value(conf->upstream.read_timeout, 2014 ngx_conf_merge_msec_value(conf->upstream.read_timeout,
1961 prev->upstream.read_timeout, 60000); 2015 prev->upstream.read_timeout, 60000);
2016
2017 ngx_conf_merge_msec_value(conf->upstream.redirect_errors,
2018 prev->upstream.redirect_errors, 0);
1962 2019
1963 ngx_conf_merge_msec_value(conf->upstream.x_powered_by, 2020 ngx_conf_merge_msec_value(conf->upstream.x_powered_by,
1964 prev->upstream.x_powered_by, 1); 2021 prev->upstream.x_powered_by, 1);
1965 2022
1966 2023
2047 return NGX_CONF_ERROR; 2104 return NGX_CONF_ERROR;
2048 } 2105 }
2049 2106
2050 2107
2051 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, 2108 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream,
2052 prev->upstream.next_upstream, 2109 prev->upstream.next_upstream,
2053 (NGX_CONF_BITMASK_SET 2110 (NGX_CONF_BITMASK_SET
2054 |NGX_HTTP_UPSTREAM_FT_ERROR 2111 |NGX_HTTP_UPSTREAM_FT_ERROR
2055 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); 2112 |NGX_HTTP_UPSTREAM_FT_TIMEOUT));
2056 2113
2057 ngx_conf_merge_path_value(conf->upstream.temp_path, 2114 ngx_conf_merge_path_value(conf->upstream.temp_path,
2058 prev->upstream.temp_path, 2115 prev->upstream.temp_path,
2059 NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0, 2116 NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0,
2060 ngx_garbage_collector_temp_handler, cf); 2117 ngx_garbage_collector_temp_handler, cf);
2061 2118
2062 2119
2063 ngx_conf_merge_bitmask_value(conf->params, prev->params, 2120 ngx_conf_merge_bitmask_value(conf->params, prev->params,
2064 (NGX_CONF_BITMASK_SET 2121 (NGX_CONF_BITMASK_SET
2065 |NGX_HTTP_FASTCGI_REMOTE_ADDR 2122 |NGX_HTTP_FASTCGI_REMOTE_ADDR
2066 |NGX_HTTP_FASTCGI_REMOTE_USER 2123 |NGX_HTTP_FASTCGI_REMOTE_USER
2067 |NGX_HTTP_FASTCGI_SERVER_NAME 2124 |NGX_HTTP_FASTCGI_SERVER_NAME
2068 |NGX_HTTP_FASTCGI_SERVER_PORT 2125 |NGX_HTTP_FASTCGI_SERVER_PORT
2069 |NGX_HTTP_FASTCGI_SCRIPT_NAME 2126 |NGX_HTTP_FASTCGI_SCRIPT_NAME
2070 |NGX_HTTP_FASTCGI_AUTH_TYPE 2127 |NGX_HTTP_FASTCGI_AUTH_TYPE
2071 |NGX_HTTP_FASTCGI_REQUEST_URI 2128 |NGX_HTTP_FASTCGI_REQUEST_URI
2072 |NGX_HTTP_FASTCGI_REDIRECT_STATUS)); 2129 |NGX_HTTP_FASTCGI_REDIRECT_STATUS));
2073 2130
2074 ngx_conf_merge_str_value(conf->root, prev->root, ""); 2131 ngx_conf_merge_str_value(conf->root, prev->root, "");
2075 2132
2076 if (conf->root.len && conf->root.data[conf->root.len - 1] == '/') { 2133 if (conf->root.len && conf->root.data[conf->root.len - 1] == '/') {
2077 conf->root.len--; 2134 conf->root.len--;
2078 } 2135 }
2079 2136
2080 ngx_conf_merge_str_value(conf->index, prev->index, ""); 2137 ngx_conf_merge_str_value(conf->index, prev->index, "");
2081 2138
2139 if (conf->vars == NULL) {
2140 conf->vars = prev->vars;
2141 }
2142
2082 return NGX_CONF_OK; 2143 return NGX_CONF_OK;
2083 } 2144 }