43 static void *ngx_http_scgi_create_loc_conf(
ngx_conf_t *cf);
44 static char *ngx_http_scgi_merge_loc_conf(
ngx_conf_t *cf,
void *parent,
196 ngx_http_scgi_cache_key,
206 &ngx_http_scgi_module },
241 &ngx_http_scgi_next_upstream_masks },
292 &ngx_http_scgi_next_upstream_masks },
336 ngx_http_scgi_create_loc_conf,
337 ngx_http_scgi_merge_loc_conf
343 &ngx_http_scgi_module_ctx,
344 ngx_http_scgi_commands,
357 static ngx_str_t ngx_http_scgi_hide_headers[] = {
398 "ngx_http_scgi_module does not support "
399 "subrequests in memory");
408 if (status == NULL) {
417 if (ngx_http_scgi_eval(r, scf) !=
NGX_OK) {
430 u->create_key = ngx_http_scgi_create_key;
442 if (u->
pipe == NULL) {
479 "%s in upstream \"%V\"", url.
err, &url.
url);
536 off_t content_length_n;
537 u_char ch, *key, *val, *lowcase_key;
538 size_t len, key_len, val_len, allocated;
551 content_length_n = 0;
562 len =
sizeof(
"CONTENT_LENGTH") + content_length.
len + 1;
578 while (*(uintptr_t *) le.
ip) {
581 key_len = lcode(&le);
584 skip_empty = lcode(&le);
586 for (val_len = 0; *(uintptr_t *) le.
ip; val_len += lcode(&le)) {
589 le.
ip +=
sizeof(uintptr_t);
591 if (skip_empty && val_len == 0) {
595 len += key_len + val_len + 1;
614 if (ignored == NULL) {
624 if (i >= part->
nelts) {
625 if (part->
next == NULL) {
635 if (allocated < header[i].key.len) {
636 allocated = header[
i].
key.
len + 16;
638 if (lowcase_key == NULL) {
645 for (n = 0; n < header[
i].
key.
len; n++) {
648 if (ch >=
'A' && ch <=
'Z') {
651 }
else if (ch ==
'-') {
660 ignored[header_params++] = &header[
i];
665 len +=
sizeof(
"HTTP_") - 1 + header[i].key.len + 1
685 len, &content_length);
697 while (*(uintptr_t *) le.
ip) {
703 skip_empty = lcode(&le);
705 for (val_len = 0; *(uintptr_t *) le.
ip; val_len += lcode(&le)) {
708 le.
ip +=
sizeof(uintptr_t);
710 if (skip_empty && val_len == 0) {
713 while (*(uintptr_t *) e.
ip) {
717 e.
ip +=
sizeof(uintptr_t);
733 while (*(uintptr_t *) e.
ip) {
738 e.
ip +=
sizeof(uintptr_t);
741 "scgi param: \"%s: %s\"", key, val);
754 if (i >= part->
nelts) {
755 if (part->
next == NULL) {
764 for (n = 0; n < header_params; n++) {
765 if (&header[i] == ignored[n]) {
773 for (n = 0; n < header[
i].
key.
len; n++) {
776 if (ch >=
'a' && ch <=
'z') {
779 }
else if (ch ==
'-') {
786 *b->
last++ = (u_char) 0;
790 *b->
last++ = (u_char) 0;
793 "scgi param: \"%s: %s\"", key, val);
801 *b->
last++ = (u_char)
',';
816 if (cl->
next == NULL) {
843 if (status == NULL) {
849 status->
start = NULL;
869 if (status == NULL) {
883 return ngx_http_scgi_process_header(r);
903 "http scgi status %ui \"%V\"",
908 return ngx_http_scgi_process_header(r);
972 "http scgi header: \"%V: %V\"", &h->
key, &h->
value);
982 "http scgi header done");
996 "upstream sent invalid status \"%V\"",
1007 "302 Moved Temporarily");
1036 "upstream sent invalid header");
1047 "abort http scgi request");
1057 "finalize http scgi request");
1064 ngx_http_scgi_create_loc_conf(
ngx_conf_t *cf)
1094 #if (NGX_HTTP_CACHE)
1121 ngx_http_scgi_merge_loc_conf(
ngx_conf_t *cf,
void *parent,
void *child)
1173 "there must be at least 2 \"scgi_buffers\"");
1179 if (size < conf->upstream.bufs.size) {
1197 "\"scgi_busy_buffers_size\" must be equal to or greater "
1198 "than the maximum of the value of \"scgi_buffer_size\" and "
1199 "one of the \"scgi_buffers\"");
1208 "\"scgi_busy_buffers_size\" must be less than "
1209 "the size of all \"scgi_buffers\" minus one buffer");
1228 "\"scgi_temp_file_write_size\" must be equal to or greater than "
1229 "the maximum of the value of \"scgi_buffer_size\" and "
1230 "one of the \"scgi_buffers\"");
1250 "\"scgi_max_temp_file_size\" must be equal to zero to disable "
1251 "temporary files usage or must be equal to or greater than "
1252 "the maximum of the value of \"scgi_buffer_size\" and "
1253 "one of the \"scgi_buffers\"");
1277 &ngx_http_scgi_temp_path)
1283 #if (NGX_HTTP_CACHE)
1294 "\"scgi_cache\" zone \"%V\" is unknown",
1317 if (conf->
upstream.cache_methods == 0) {
1324 prev->
upstream.cache_bypass, NULL);
1332 if (conf->cache_key.value.data == NULL) {
1333 conf->cache_key = prev->cache_key;
1340 prev->
upstream.cache_lock_timeout, 5000);
1354 hash.
name =
"scgi_hide_headers_hash";
1357 &prev->
upstream, ngx_http_scgi_hide_headers, &hash)
1375 clcf->
handler = ngx_http_scgi_handler;
1379 if (ngx_http_scgi_merge_params(cf, conf, prev) !=
NGX_OK) {
1396 #if (NGX_HTTP_CACHE)
1441 if (conf->
params == NULL) {
1460 #if (NGX_HTTP_CACHE)
1466 if (ngx_array_init(¶ms_merged, cf->
temp_pool, 4,
1473 for (i = 0; i < nsrc; i++) {
1483 h = ngx_http_scgi_cache_headers;
1487 src = params_merged.
elts;
1488 nsrc = params_merged.
nelts;
1490 for (i = 0; i < nsrc; i++) {
1510 src = params_merged.
elts;
1511 nsrc = params_merged.
nelts;
1516 for (i = 0; i < nsrc; i++) {
1518 if (src[i].key.len >
sizeof(
"HTTP_") - 1
1519 &&
ngx_strncmp(src[i].key.data,
"HTTP_",
sizeof(
"HTTP_") - 1) == 0)
1529 hk->
value = (
void *) 1;
1531 if (src[i].value.len == 0) {
1556 + src[i].key.len + 1 +
sizeof(uintptr_t) - 1)
1557 & ~(
sizeof(uintptr_t) - 1);
1588 *code = (uintptr_t) NULL;
1596 *code = (uintptr_t) NULL;
1604 *code = (uintptr_t) NULL;
1611 *code = (uintptr_t) NULL;
1619 hash.
name =
"scgi_params_hash";
1639 return "is duplicate";
1643 clcf->
handler = ngx_http_scgi_handler;
1697 return "is duplicate";
1707 #if (NGX_HTTP_CACHE)
1712 return "is incompatible with \"scgi_cache\"";
1743 #if (NGX_HTTP_CACHE)
1755 return "is duplicate";
1764 return "is incompatible with \"scgi_store\"";
1768 &ngx_http_scgi_module);
1787 if (scf->cache_key.value.data) {
1788 return "is duplicate";
1794 ccv.
value = &value[1];