135
135
ngx_command_t *cmd, void *conf);
138
static ngx_http_fastcgi_request_start_t ngx_http_fastcgi_request_start = {
140
NGX_HTTP_FASTCGI_BEGIN_REQUEST, /* type */
141
0, /* request_id_hi */
142
1, /* request_id_lo */
143
0, /* content_length_hi */
144
sizeof(ngx_http_fastcgi_begin_request_t), /* content_length_lo */
145
0, /* padding_length */
149
NGX_HTTP_FASTCGI_RESPONDER, /* role_lo */
150
0, /* NGX_HTTP_FASTCGI_KEEP_CONN */ /* flags */
151
{ 0, 0, 0, 0, 0 } }, /* reserved[5] */
154
NGX_HTTP_FASTCGI_PARAMS, /* type */
155
0, /* request_id_hi */
156
1 }, /* request_id_lo */
161
static ngx_str_t ngx_http_fastcgi_script_name =
162
ngx_string("fastcgi_script_name");
165
138
static ngx_conf_post_t ngx_http_fastcgi_lowat_post =
166
139
{ ngx_http_fastcgi_lowat_check };
388
static ngx_http_fastcgi_request_start_t ngx_http_fastcgi_request_start = {
390
NGX_HTTP_FASTCGI_BEGIN_REQUEST, /* type */
391
0, /* request_id_hi */
392
1, /* request_id_lo */
393
0, /* content_length_hi */
394
sizeof(ngx_http_fastcgi_begin_request_t), /* content_length_lo */
395
0, /* padding_length */
399
NGX_HTTP_FASTCGI_RESPONDER, /* role_lo */
400
0, /* NGX_HTTP_FASTCGI_KEEP_CONN */ /* flags */
401
{ 0, 0, 0, 0, 0 } }, /* reserved[5] */
404
NGX_HTTP_FASTCGI_PARAMS, /* type */
405
0, /* request_id_hi */
406
1 }, /* request_id_lo */
411
static ngx_str_t ngx_http_fastcgi_script_name =
412
ngx_string("fastcgi_script_name");
415
415
static ngx_str_t ngx_http_fastcgi_hide_headers[] = {
416
416
ngx_string("Status"),
417
417
ngx_string("X-Accel-Expires"),
418
418
ngx_string("X-Accel-Redirect"),
419
419
ngx_string("X-Accel-Limit-Rate"),
420
ngx_string("X-Accel-Buffer"),
420
ngx_string("X-Accel-Buffering"),
421
ngx_string("X-Accel-Charset"),
432
433
if (r->subrequest_in_memory) {
433
434
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
434
435
"ngx_http_fastcgi_module does not support "
435
"subrequest in memeory");
436
"subrequest in memory");
436
437
return NGX_HTTP_INTERNAL_SERVER_ERROR;
636
639
code((ngx_http_script_engine_t *) &e);
638
641
e.ip += sizeof(uintptr_t);
643
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
644
"fastcgi param: \"%*s: %*s\"",
645
key_len, e.pos - (key_len + val_len),
646
val_len, e.pos - val_len);
1143
1151
h->lowcase_key, h->key.len);
1145
1153
if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
1146
return NGX_HTTP_INTERNAL_SERVER_ERROR;
1149
1157
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1172
1180
status = ngx_atoi(status_line->data, 3);
1174
1182
if (status == NGX_ERROR) {
1175
return NGX_HTTP_INTERNAL_SERVER_ERROR;
1183
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1184
"upstream sent invalid status \"%V\"",
1186
return NGX_HTTP_UPSTREAM_INVALID_HEADER;
1178
1189
u->headers_in.status_n = status;
1179
1190
u->headers_in.status_line = *status_line;
1192
} else if (u->headers_in.location) {
1193
u->headers_in.status_n = 302;
1194
u->headers_in.status_line.len =
1195
sizeof("302 Moved Temporarily") - 1;
1196
u->headers_in.status_line.data =
1197
(u_char *) "302 Moved Temporarily";
1182
1200
u->headers_in.status_n = 200;
1183
1201
u->headers_in.status_line.len = sizeof("200 OK") - 1;
1638
1656
* conf->upstream.next_upstream = 0;
1639
1657
* conf->upstream.temp_path = NULL;
1640
1658
* conf->upstream.hide_headers_hash = { NULL, 0 };
1641
* conf->upstream.hide_headers = NULL;
1642
* conf->upstream.pass_headers = NULL;
1643
1659
* conf->upstream.schema = { 0, NULL };
1644
1660
* conf->upstream.uri = { 0, NULL };
1645
1661
* conf->upstream.location = NULL;
1669
1685
conf->upstream.pass_request_headers = NGX_CONF_UNSET;
1670
1686
conf->upstream.pass_request_body = NGX_CONF_UNSET;
1688
conf->upstream.hide_headers = NGX_CONF_UNSET_PTR;
1689
conf->upstream.pass_headers = NGX_CONF_UNSET_PTR;
1672
1691
conf->upstream.intercept_errors = NGX_CONF_UNSET;
1674
1693
/* "fastcgi_cyclic_temp_file" is disabled */
1856
1872
ngx_conf_merge_str_value(conf->index, prev->index, "");
1858
if (conf->upstream.hide_headers == NULL
1859
&& conf->upstream.pass_headers == NULL)
1861
conf->upstream.hide_headers = prev->upstream.hide_headers;
1862
conf->upstream.pass_headers = prev->upstream.pass_headers;
1863
conf->upstream.hide_headers_hash = prev->upstream.hide_headers_hash;
1865
if (conf->upstream.hide_headers_hash.buckets) {
1870
if (conf->upstream.hide_headers == NULL) {
1871
conf->upstream.hide_headers = prev->upstream.hide_headers;
1874
if (conf->upstream.pass_headers == NULL) {
1875
conf->upstream.pass_headers = prev->upstream.pass_headers;
1879
if (ngx_array_init(&hide_headers, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
1882
return NGX_CONF_ERROR;
1885
for (header = ngx_http_fastcgi_hide_headers; header->len; header++) {
1886
hk = ngx_array_push(&hide_headers);
1888
return NGX_CONF_ERROR;
1892
hk->key_hash = ngx_hash_key_lc(header->data, header->len);
1893
hk->value = (void *) 1;
1896
if (conf->upstream.hide_headers) {
1898
header = conf->upstream.hide_headers->elts;
1900
for (i = 0; i < conf->upstream.hide_headers->nelts; i++) {
1902
hk = hide_headers.elts;
1904
for (j = 0; j < hide_headers.nelts; j++) {
1905
if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) {
1910
hk = ngx_array_push(&hide_headers);
1912
return NGX_CONF_ERROR;
1915
hk->key = header[i];
1916
hk->key_hash = ngx_hash_key_lc(header[i].data, header[i].len);
1917
hk->value = (void *) 1;
1925
if (conf->upstream.pass_headers) {
1927
hk = hide_headers.elts;
1928
header = conf->upstream.pass_headers->elts;
1930
for (i = 0; i < conf->upstream.pass_headers->nelts; i++) {
1932
for (j = 0; j < hide_headers.nelts; j++) {
1934
if (hk[j].key.data == NULL) {
1938
if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) {
1939
hk[j].key.data = NULL;
1946
hash.hash = &conf->upstream.hide_headers_hash;
1947
hash.key = ngx_hash_key_lc;
1948
1874
hash.max_size = 512;
1949
1875
hash.bucket_size = ngx_align(64, ngx_cacheline_size);
1950
1876
hash.name = "fastcgi_hide_headers_hash";
1951
hash.pool = cf->pool;
1952
hash.temp_pool = NULL;
1954
if (ngx_hash_init(&hash, hide_headers.elts, hide_headers.nelts) != NGX_OK) {
1878
if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
1880
ngx_http_fastcgi_hide_headers,
1955
1884
return NGX_CONF_ERROR;
1960
1887
if (conf->upstream.upstream == NULL) {
1961
1888
conf->upstream.upstream = prev->upstream.upstream;
1962
1889
conf->upstream.schema = prev->upstream.schema;