annotate src/http/modules/ngx_http_scgi_module.c @ 5575:d15822784cf9

Upstream: fix $upstream_status variable. Previously, upstream's status code was overwritten with cached response's status code when STALE or REVALIDATED response was sent to the client. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
author Piotr Sikora <piotr@cloudflare.com>
date Tue, 11 Feb 2014 21:54:42 -0800
parents 9d056f10fb99
children c95d7882dfc9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 /*
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 4401
diff changeset
4 * Copyright (C) Nginx, Inc.
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5 * Copyright (C) Manlio Perillo (manlio.perillo@gmail.com)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6 */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #include <ngx_config.h>
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10 #include <ngx_core.h>
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11 #include <ngx_http.h>
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14 typedef struct {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15 ngx_http_upstream_conf_t upstream;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17 ngx_array_t *flushes;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18 ngx_array_t *params_len;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19 ngx_array_t *params;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20 ngx_array_t *params_source;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
21
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22 ngx_hash_t headers_hash;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 ngx_uint_t header_params;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
24
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25 ngx_array_t *scgi_lengths;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26 ngx_array_t *scgi_values;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29 ngx_http_complex_value_t cache_key;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31 } ngx_http_scgi_loc_conf_t;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34 static ngx_int_t ngx_http_scgi_eval(ngx_http_request_t *r,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35 ngx_http_scgi_loc_conf_t *scf);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
36 static ngx_int_t ngx_http_scgi_create_request(ngx_http_request_t *r);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37 static ngx_int_t ngx_http_scgi_reinit_request(ngx_http_request_t *r);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38 static ngx_int_t ngx_http_scgi_process_status_line(ngx_http_request_t *r);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39 static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40 static void ngx_http_scgi_abort_request(ngx_http_request_t *r);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41 static void ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 static void *ngx_http_scgi_create_loc_conf(ngx_conf_t *cf);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 static char *ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45 void *child);
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
46 static ngx_int_t ngx_http_scgi_merge_params(ngx_conf_t *cf,
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
47 ngx_http_scgi_loc_conf_t *conf, ngx_http_scgi_loc_conf_t *prev);
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
49 static char *ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
50 static char *ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
51 void *conf);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
52
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
53 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
54 static ngx_int_t ngx_http_scgi_create_key(ngx_http_request_t *r);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
55 static char *ngx_http_scgi_cache(ngx_conf_t *cf, ngx_command_t *cmd,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
56 void *conf);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
57 static char *ngx_http_scgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
58 void *conf);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
59 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
60
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
61
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
62 static ngx_conf_bitmask_t ngx_http_scgi_next_upstream_masks[] = {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
63 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
64 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
65 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
66 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
67 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
5231
05c53652e7b4 Upstream: http_403 support in proxy_next_upstream (and friends).
Maxim Dounin <mdounin@mdounin.ru>
parents: 5080
diff changeset
68 { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
69 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
70 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
71 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
72 { ngx_null_string, 0 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
73 };
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
74
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
75
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
76 ngx_module_t ngx_http_scgi_module;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
77
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
78
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
79 static ngx_command_t ngx_http_scgi_commands[] = {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
80
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
81 { ngx_string("scgi_pass"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
82 NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
83 ngx_http_scgi_pass,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
84 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
85 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
86 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
87
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
88 { ngx_string("scgi_store"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
89 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
90 ngx_http_scgi_store,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
91 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
92 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
93 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
94
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
95 { ngx_string("scgi_store_access"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
96 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
97 ngx_conf_set_access_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
98 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
99 offsetof(ngx_http_scgi_loc_conf_t, upstream.store_access),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
100 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
101
4157
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
102 { ngx_string("scgi_buffering"),
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
103 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
104 ngx_conf_set_flag_slot,
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
105 NGX_HTTP_LOC_CONF_OFFSET,
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
106 offsetof(ngx_http_scgi_loc_conf_t, upstream.buffering),
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
107 NULL },
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
108
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
109 { ngx_string("scgi_ignore_client_abort"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
110 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
111 ngx_conf_set_flag_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
112 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
113 offsetof(ngx_http_scgi_loc_conf_t, upstream.ignore_client_abort),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
114 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
115
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
116 { ngx_string("scgi_bind"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
117 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
118 ngx_http_upstream_bind_set_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
119 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
120 offsetof(ngx_http_scgi_loc_conf_t, upstream.local),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
121 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
122
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
123 { ngx_string("scgi_connect_timeout"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
124 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
125 ngx_conf_set_msec_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
126 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
127 offsetof(ngx_http_scgi_loc_conf_t, upstream.connect_timeout),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
128 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
129
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
130 { ngx_string("scgi_send_timeout"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
131 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
132 ngx_conf_set_msec_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
133 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
134 offsetof(ngx_http_scgi_loc_conf_t, upstream.send_timeout),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
135 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
136
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
137 { ngx_string("scgi_buffer_size"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
138 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
139 ngx_conf_set_size_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
140 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
141 offsetof(ngx_http_scgi_loc_conf_t, upstream.buffer_size),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
142 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
143
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
144 { ngx_string("scgi_pass_request_headers"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
145 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
146 ngx_conf_set_flag_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
147 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
148 offsetof(ngx_http_scgi_loc_conf_t, upstream.pass_request_headers),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
149 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
150
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
151 { ngx_string("scgi_pass_request_body"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
152 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
153 ngx_conf_set_flag_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
154 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
155 offsetof(ngx_http_scgi_loc_conf_t, upstream.pass_request_body),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
156 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
157
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
158 { ngx_string("scgi_intercept_errors"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
159 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
160 ngx_conf_set_flag_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
161 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
162 offsetof(ngx_http_scgi_loc_conf_t, upstream.intercept_errors),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
163 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
164
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
165 { ngx_string("scgi_read_timeout"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
166 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
167 ngx_conf_set_msec_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
168 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
169 offsetof(ngx_http_scgi_loc_conf_t, upstream.read_timeout),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
170 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
171
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
172 { ngx_string("scgi_buffers"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
173 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
174 ngx_conf_set_bufs_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
175 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
176 offsetof(ngx_http_scgi_loc_conf_t, upstream.bufs),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
177 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
178
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
179 { ngx_string("scgi_busy_buffers_size"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
180 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
181 ngx_conf_set_size_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
182 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
183 offsetof(ngx_http_scgi_loc_conf_t, upstream.busy_buffers_size_conf),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
184 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
185
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
186 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
187
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
188 { ngx_string("scgi_cache"),
3729
4b773fc06336 fix directive type
Igor Sysoev <igor@sysoev.ru>
parents: 3699
diff changeset
189 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
190 ngx_http_scgi_cache,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
191 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
192 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
193 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
194
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
195 { ngx_string("scgi_cache_key"),
3729
4b773fc06336 fix directive type
Igor Sysoev <igor@sysoev.ru>
parents: 3699
diff changeset
196 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
197 ngx_http_scgi_cache_key,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
198 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
199 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
200 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
201
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
202 { ngx_string("scgi_cache_path"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
203 NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
204 ngx_http_file_cache_set_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
205 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
206 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
207 &ngx_http_scgi_module },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
208
3699
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
209 { ngx_string("scgi_cache_bypass"),
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
210 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
211 ngx_http_set_predicate_slot,
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
212 NGX_HTTP_LOC_CONF_OFFSET,
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
213 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_bypass),
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
214 NULL },
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
215
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
216 { ngx_string("scgi_no_cache"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
217 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
3692
045ea40cbfe8 use ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents: 3670
diff changeset
218 ngx_http_set_predicate_slot,
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
219 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
220 offsetof(ngx_http_scgi_loc_conf_t, upstream.no_cache),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
221 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
222
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
223 { ngx_string("scgi_cache_valid"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
224 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
225 ngx_http_file_cache_valid_set_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
226 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
227 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_valid),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
228 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
229
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
230 { ngx_string("scgi_cache_min_uses"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
231 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
232 ngx_conf_set_num_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
233 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
234 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_min_uses),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
235 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
236
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
237 { ngx_string("scgi_cache_use_stale"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
238 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
239 ngx_conf_set_bitmask_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
240 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
241 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_use_stale),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
242 &ngx_http_scgi_next_upstream_masks },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
243
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
244 { ngx_string("scgi_cache_methods"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
245 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
246 ngx_conf_set_bitmask_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
247 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
248 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_methods),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
249 &ngx_http_upstream_cache_method_mask },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
250
4386
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
251 { ngx_string("scgi_cache_lock"),
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
252 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
253 ngx_conf_set_flag_slot,
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
254 NGX_HTTP_LOC_CONF_OFFSET,
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
255 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock),
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
256 NULL },
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
257
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
258 { ngx_string("scgi_cache_lock_timeout"),
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
259 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
260 ngx_conf_set_msec_slot,
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
261 NGX_HTTP_LOC_CONF_OFFSET,
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
262 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock_timeout),
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
263 NULL },
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
264
5441
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
265 { ngx_string("scgi_cache_revalidate"),
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
266 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
267 ngx_conf_set_flag_slot,
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
268 NGX_HTTP_LOC_CONF_OFFSET,
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
269 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_revalidate),
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
270 NULL },
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
271
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
272 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
273
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
274 { ngx_string("scgi_temp_path"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
275 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
276 ngx_conf_set_path_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
277 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
278 offsetof(ngx_http_scgi_loc_conf_t, upstream.temp_path),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
279 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
280
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
281 { ngx_string("scgi_max_temp_file_size"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
282 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
283 ngx_conf_set_size_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
284 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
285 offsetof(ngx_http_scgi_loc_conf_t, upstream.max_temp_file_size_conf),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
286 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
287
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
288 { ngx_string("scgi_temp_file_write_size"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
289 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
290 ngx_conf_set_size_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
291 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
292 offsetof(ngx_http_scgi_loc_conf_t, upstream.temp_file_write_size_conf),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
293 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
294
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
295 { ngx_string("scgi_next_upstream"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
296 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
297 ngx_conf_set_bitmask_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
298 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
299 offsetof(ngx_http_scgi_loc_conf_t, upstream.next_upstream),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
300 &ngx_http_scgi_next_upstream_masks },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
301
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
302 { ngx_string("scgi_param"),
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
303 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23,
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
304 ngx_http_upstream_param_set_slot,
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
305 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
306 offsetof(ngx_http_scgi_loc_conf_t, params_source),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
307 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
308
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
309 { ngx_string("scgi_pass_header"),
3729
4b773fc06336 fix directive type
Igor Sysoev <igor@sysoev.ru>
parents: 3699
diff changeset
310 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
311 ngx_conf_set_str_array_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
312 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
313 offsetof(ngx_http_scgi_loc_conf_t, upstream.pass_headers),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
314 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
315
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
316 { ngx_string("scgi_hide_header"),
3729
4b773fc06336 fix directive type
Igor Sysoev <igor@sysoev.ru>
parents: 3699
diff changeset
317 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
318 ngx_conf_set_str_array_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
319 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
320 offsetof(ngx_http_scgi_loc_conf_t, upstream.hide_headers),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
321 NULL },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
322
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
323 { ngx_string("scgi_ignore_headers"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
324 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
325 ngx_conf_set_bitmask_slot,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
326 NGX_HTTP_LOC_CONF_OFFSET,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
327 offsetof(ngx_http_scgi_loc_conf_t, upstream.ignore_headers),
3667
12bd9e26fadb use shared ngx_http_upstream_ignore_headers_masks[]
Igor Sysoev <igor@sysoev.ru>
parents: 3637
diff changeset
328 &ngx_http_upstream_ignore_headers_masks },
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
329
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
330 ngx_null_command
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
331 };
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
332
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
333
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
334 static ngx_http_module_t ngx_http_scgi_module_ctx = {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
335 NULL, /* preconfiguration */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
336 NULL, /* postconfiguration */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
337
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
338 NULL, /* create main configuration */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
339 NULL, /* init main configuration */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
340
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
341 NULL, /* create server configuration */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
342 NULL, /* merge server configuration */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
343
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
344 ngx_http_scgi_create_loc_conf, /* create location configuration */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
345 ngx_http_scgi_merge_loc_conf /* merge location configuration */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
346 };
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
347
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
348
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
349 ngx_module_t ngx_http_scgi_module = {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
350 NGX_MODULE_V1,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
351 &ngx_http_scgi_module_ctx, /* module context */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
352 ngx_http_scgi_commands, /* module directives */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
353 NGX_HTTP_MODULE, /* module type */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
354 NULL, /* init master */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
355 NULL, /* init module */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
356 NULL, /* init process */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
357 NULL, /* init thread */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
358 NULL, /* exit thread */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
359 NULL, /* exit process */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
360 NULL, /* exit master */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
361 NGX_MODULE_V1_PADDING
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
362 };
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
363
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
364
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
365 static ngx_str_t ngx_http_scgi_hide_headers[] = {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
366 ngx_string("Status"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
367 ngx_string("X-Accel-Expires"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
368 ngx_string("X-Accel-Redirect"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
369 ngx_string("X-Accel-Limit-Rate"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
370 ngx_string("X-Accel-Buffering"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
371 ngx_string("X-Accel-Charset"),
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
372 ngx_null_string
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
373 };
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
374
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
375
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
376 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
377
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
378 static ngx_keyval_t ngx_http_scgi_cache_headers[] = {
5441
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
379 { ngx_string("HTTP_IF_MODIFIED_SINCE"),
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
380 ngx_string("$upstream_cache_last_modified") },
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
381 { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
382 { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
383 { ngx_string("HTTP_IF_MATCH"), ngx_string("") },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
384 { ngx_string("HTTP_RANGE"), ngx_string("") },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
385 { ngx_string("HTTP_IF_RANGE"), ngx_string("") },
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
386 { ngx_null_string, ngx_null_string }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
387 };
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
388
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
389 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
390
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
391
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
392 static ngx_path_init_t ngx_http_scgi_temp_path = {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
393 ngx_string(NGX_HTTP_SCGI_TEMP_PATH), { 1, 2, 0 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
394 };
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
395
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
396
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
397 static ngx_int_t
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
398 ngx_http_scgi_handler(ngx_http_request_t *r)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
399 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
400 ngx_int_t rc;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
401 ngx_http_status_t *status;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
402 ngx_http_upstream_t *u;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
403 ngx_http_scgi_loc_conf_t *scf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
404
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
405 if (ngx_http_upstream_create(r) != NGX_OK) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
406 return NGX_HTTP_INTERNAL_SERVER_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
407 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
408
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
409 status = ngx_pcalloc(r->pool, sizeof(ngx_http_status_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
410 if (status == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
411 return NGX_HTTP_INTERNAL_SERVER_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
412 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
413
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
414 ngx_http_set_ctx(r, status, ngx_http_scgi_module);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
415
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
416 scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
417
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
418 if (scf->scgi_lengths) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
419 if (ngx_http_scgi_eval(r, scf) != NGX_OK) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
420 return NGX_HTTP_INTERNAL_SERVER_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
421 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
422 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
423
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
424 u = r->upstream;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
425
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
426 ngx_str_set(&u->schema, "scgi://");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
427 u->output.tag = (ngx_buf_tag_t) &ngx_http_scgi_module;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
428
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
429 u->conf = &scf->upstream;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
430
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
431 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
432 u->create_key = ngx_http_scgi_create_key;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
433 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
434 u->create_request = ngx_http_scgi_create_request;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
435 u->reinit_request = ngx_http_scgi_reinit_request;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
436 u->process_header = ngx_http_scgi_process_status_line;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
437 u->abort_request = ngx_http_scgi_abort_request;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
438 u->finalize_request = ngx_http_scgi_finalize_request;
4615
adcd60233817 Added r->state reset on fastcgi/scgi/uwsgi request start.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4593
diff changeset
439 r->state = 0;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
440
4157
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
441 u->buffering = scf->upstream.buffering;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
442
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
443 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
444 if (u->pipe == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
445 return NGX_HTTP_INTERNAL_SERVER_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
446 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
447
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
448 u->pipe->input_filter = ngx_event_pipe_copy_input_filter;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
449 u->pipe->input_ctx = r;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
450
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
451 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
452
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
453 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
454 return rc;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
455 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
456
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
457 return NGX_DONE;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
458 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
459
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
460
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
461 static ngx_int_t
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
462 ngx_http_scgi_eval(ngx_http_request_t *r, ngx_http_scgi_loc_conf_t * scf)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
463 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
464 ngx_url_t url;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
465 ngx_http_upstream_t *u;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
466
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
467 ngx_memzero(&url, sizeof(ngx_url_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
468
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
469 if (ngx_http_script_run(r, &url.url, scf->scgi_lengths->elts, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
470 scf->scgi_values->elts)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
471 == NULL)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
472 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
473 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
474 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
475
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
476 url.no_resolve = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
477
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
478 if (ngx_parse_url(r->pool, &url) != NGX_OK) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
479 if (url.err) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
480 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
481 "%s in upstream \"%V\"", url.err, &url.url);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
482 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
483
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
484 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
485 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
486
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
487 u = r->upstream;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
488
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
489 u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
490 if (u->resolved == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
491 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
492 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
493
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
494 if (url.addrs && url.addrs[0].sockaddr) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
495 u->resolved->sockaddr = url.addrs[0].sockaddr;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
496 u->resolved->socklen = url.addrs[0].socklen;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
497 u->resolved->naddrs = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
498 u->resolved->host = url.addrs[0].name;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
499
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
500 } else {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
501 u->resolved->host = url.host;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
502 u->resolved->port = url.port;
3879
502a6b0acf3f fix case when a host in fastcgi_pass, scgi_pass, and uwsgi_pass
Igor Sysoev <igor@sysoev.ru>
parents: 3731
diff changeset
503 u->resolved->no_port = url.no_port;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
504 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
505
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
506 return NGX_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
507 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
508
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
509
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
510 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
511
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
512 static ngx_int_t
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
513 ngx_http_scgi_create_key(ngx_http_request_t *r)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
514 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
515 ngx_str_t *key;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
516 ngx_http_scgi_loc_conf_t *scf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
517
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
518 key = ngx_array_push(&r->cache->keys);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
519 if (key == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
520 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
521 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
522
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
523 scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
524
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
525 if (ngx_http_complex_value(r, &scf->cache_key, key) != NGX_OK) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
526 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
527 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
528
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
529 return NGX_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
530 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
531
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
532 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
533
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
534
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
535 static ngx_int_t
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
536 ngx_http_scgi_create_request(ngx_http_request_t *r)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
537 {
4929
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
538 off_t content_length_n;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
539 u_char ch, *key, *val, *lowcase_key;
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
540 size_t len, key_len, val_len, allocated;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
541 ngx_buf_t *b;
4929
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
542 ngx_str_t content_length;
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
543 ngx_uint_t i, n, hash, skip_empty, header_params;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
544 ngx_chain_t *cl, *body;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
545 ngx_list_part_t *part;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
546 ngx_table_elt_t *header, **ignored;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
547 ngx_http_script_code_pt code;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
548 ngx_http_script_engine_t e, le;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
549 ngx_http_scgi_loc_conf_t *scf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
550 ngx_http_script_len_code_pt lcode;
4929
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
551 u_char buffer[NGX_OFF_T_LEN];
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
552
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
553 content_length_n = 0;
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
554 body = r->upstream->request_bufs;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
555
4929
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
556 while (body) {
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
557 content_length_n += ngx_buf_size(body->buf);
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
558 body = body->next;
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
559 }
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
560
4929
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
561 content_length.data = buffer;
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
562 content_length.len = ngx_sprintf(buffer, "%O", content_length_n) - buffer;
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
563
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
564 len = sizeof("CONTENT_LENGTH") + content_length.len + 1;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
565
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
566 header_params = 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
567 ignored = NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
568
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
569 scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
570
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
571 if (scf->params_len) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
572 ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
573
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
574 ngx_http_script_flush_no_cacheable_variables(r, scf->flushes);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
575 le.flushed = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
576
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
577 le.ip = scf->params_len->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
578 le.request = r;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
579
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
580 while (*(uintptr_t *) le.ip) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
581
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
582 lcode = *(ngx_http_script_len_code_pt *) le.ip;
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
583 key_len = lcode(&le);
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
584
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
585 lcode = *(ngx_http_script_len_code_pt *) le.ip;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
586 skip_empty = lcode(&le);
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
587
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
588 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
589 lcode = *(ngx_http_script_len_code_pt *) le.ip;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
590 }
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
591 le.ip += sizeof(uintptr_t);
4294
56cb2255735a Fixed incorrect counting the length of headers in a SCGI request.
Valentin Bartenev <vbart@nginx.com>
parents: 4278
diff changeset
592
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
593 if (skip_empty && val_len == 0) {
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
594 continue;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
595 }
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
596
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
597 len += key_len + val_len + 1;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
598 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
599 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
600
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
601 if (scf->upstream.pass_request_headers) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
602
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
603 allocated = 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
604 lowcase_key = NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
605
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
606 if (scf->header_params) {
4015
e0a435f5f504 Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 3976
diff changeset
607 n = 0;
e0a435f5f504 Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 3976
diff changeset
608 part = &r->headers_in.headers.part;
e0a435f5f504 Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 3976
diff changeset
609
e0a435f5f504 Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 3976
diff changeset
610 while (part) {
e0a435f5f504 Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 3976
diff changeset
611 n += part->nelts;
e0a435f5f504 Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 3976
diff changeset
612 part = part->next;
e0a435f5f504 Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 3976
diff changeset
613 }
e0a435f5f504 Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 3976
diff changeset
614
e0a435f5f504 Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 3976
diff changeset
615 ignored = ngx_palloc(r->pool, n * sizeof(void *));
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
616 if (ignored == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
617 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
618 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
619 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
620
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
621 part = &r->headers_in.headers.part;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
622 header = part->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
623
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
624 for (i = 0; /* void */; i++) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
625
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
626 if (i >= part->nelts) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
627 if (part->next == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
628 break;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
629 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
630
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
631 part = part->next;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
632 header = part->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
633 i = 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
634 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
635
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
636 if (scf->header_params) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
637 if (allocated < header[i].key.len) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
638 allocated = header[i].key.len + 16;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
639 lowcase_key = ngx_pnalloc(r->pool, allocated);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
640 if (lowcase_key == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
641 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
642 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
643 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
644
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
645 hash = 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
646
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
647 for (n = 0; n < header[i].key.len; n++) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
648 ch = header[i].key.data[n];
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
649
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
650 if (ch >= 'A' && ch <= 'Z') {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
651 ch |= 0x20;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
652
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
653 } else if (ch == '-') {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
654 ch = '_';
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
655 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
656
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
657 hash = ngx_hash(hash, ch);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
658 lowcase_key[n] = ch;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
659 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
660
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
661 if (ngx_hash_find(&scf->headers_hash, hash, lowcase_key, n)) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
662 ignored[header_params++] = &header[i];
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
663 continue;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
664 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
665 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
666
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
667 len += sizeof("HTTP_") - 1 + header[i].key.len + 1
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
668 + header[i].value.len + 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
669 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
670 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
671
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
672 /* netstring: "length:" + packet + "," */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
673
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
674 b = ngx_create_temp_buf(r->pool, NGX_SIZE_T_LEN + 1 + len + 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
675 if (b == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
676 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
677 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
678
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
679 cl = ngx_alloc_chain_link(r->pool);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
680 if (cl == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
681 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
682 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
683
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
684 cl->buf = b;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
685
4929
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
686 b->last = ngx_sprintf(b->last, "%ui:CONTENT_LENGTH%Z%V%Z",
5a44d638cd27 Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4615
diff changeset
687 len, &content_length);
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
688
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
689 if (scf->params_len) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
690 ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
691
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
692 e.ip = scf->params->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
693 e.pos = b->last;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
694 e.request = r;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
695 e.flushed = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
696
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
697 le.ip = scf->params_len->elts;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
698
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
699 while (*(uintptr_t *) le.ip) {
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
700
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
701 lcode = *(ngx_http_script_len_code_pt *) le.ip;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
702 lcode(&le); /* key length */
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
703
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
704 lcode = *(ngx_http_script_len_code_pt *) le.ip;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
705 skip_empty = lcode(&le);
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
706
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
707 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
708 lcode = *(ngx_http_script_len_code_pt *) le.ip;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
709 }
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
710 le.ip += sizeof(uintptr_t);
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
711
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
712 if (skip_empty && val_len == 0) {
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
713 e.skip = 1;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
714
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
715 while (*(uintptr_t *) e.ip) {
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
716 code = *(ngx_http_script_code_pt *) e.ip;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
717 code((ngx_http_script_engine_t *) &e);
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
718 }
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
719 e.ip += sizeof(uintptr_t);
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
720
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
721 e.skip = 0;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
722
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
723 continue;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
724 }
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
725
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
726 #if (NGX_DEBUG)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
727 key = e.pos;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
728 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
729 code = *(ngx_http_script_code_pt *) e.ip;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
730 code((ngx_http_script_engine_t *) & e);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
731
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
732 #if (NGX_DEBUG)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
733 val = e.pos;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
734 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
735 while (*(uintptr_t *) e.ip) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
736 code = *(ngx_http_script_code_pt *) e.ip;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
737 code((ngx_http_script_engine_t *) &e);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
738 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
739 *e.pos++ = '\0';
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
740 e.ip += sizeof(uintptr_t);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
741
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
742 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
743 "scgi param: \"%s: %s\"", key, val);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
744 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
745
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
746 b->last = e.pos;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
747 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
748
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
749 if (scf->upstream.pass_request_headers) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
750
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
751 part = &r->headers_in.headers.part;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
752 header = part->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
753
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
754 for (i = 0; /* void */; i++) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
755
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
756 if (i >= part->nelts) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
757 if (part->next == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
758 break;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
759 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
760
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
761 part = part->next;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
762 header = part->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
763 i = 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
764 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
765
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
766 for (n = 0; n < header_params; n++) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
767 if (&header[i] == ignored[n]) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
768 goto next;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
769 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
770 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
771
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
772 key = b->last;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
773 b->last = ngx_cpymem(key, "HTTP_", sizeof("HTTP_") - 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
774
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
775 for (n = 0; n < header[i].key.len; n++) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
776 ch = header[i].key.data[n];
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
777
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
778 if (ch >= 'a' && ch <= 'z') {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
779 ch &= ~0x20;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
780
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
781 } else if (ch == '-') {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
782 ch = '_';
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
783 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
784
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
785 *b->last++ = ch;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
786 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
787
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
788 *b->last++ = (u_char) 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
789
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
790 val = b->last;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
791 b->last = ngx_copy(val, header[i].value.data, header[i].value.len);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
792 *b->last++ = (u_char) 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
793
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
794 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
795 "scgi param: \"%s: %s\"", key, val);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
796
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
797 next:
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
798
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
799 continue;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
800 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
801 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
802
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
803 *b->last++ = (u_char) ',';
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
804
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
805 if (scf->upstream.pass_request_body) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
806 body = r->upstream->request_bufs;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
807 r->upstream->request_bufs = cl;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
808
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
809 while (body) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
810 b = ngx_alloc_buf(r->pool);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
811 if (b == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
812 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
813 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
814
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
815 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
816
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
817 cl->next = ngx_alloc_chain_link(r->pool);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
818 if (cl->next == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
819 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
820 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
821
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
822 cl = cl->next;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
823 cl->buf = b;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
824
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
825 body = body->next;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
826 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
827
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
828 } else {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
829 r->upstream->request_bufs = cl;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
830 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
831
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
832 cl->next = NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
833
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
834 return NGX_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
835 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
836
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
837
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
838 static ngx_int_t
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
839 ngx_http_scgi_reinit_request(ngx_http_request_t *r)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
840 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
841 ngx_http_status_t *status;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
842
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
843 status = ngx_http_get_module_ctx(r, ngx_http_scgi_module);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
844
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
845 if (status == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
846 return NGX_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
847 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
848
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
849 status->code = 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
850 status->count = 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
851 status->start = NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
852 status->end = NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
853
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
854 r->upstream->process_header = ngx_http_scgi_process_status_line;
4615
adcd60233817 Added r->state reset on fastcgi/scgi/uwsgi request start.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4593
diff changeset
855 r->state = 0;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
856
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
857 return NGX_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
858 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
859
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
860
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
861 static ngx_int_t
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
862 ngx_http_scgi_process_status_line(ngx_http_request_t *r)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
863 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
864 size_t len;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
865 ngx_int_t rc;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
866 ngx_http_status_t *status;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
867 ngx_http_upstream_t *u;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
868
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
869 status = ngx_http_get_module_ctx(r, ngx_http_scgi_module);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
870
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
871 if (status == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
872 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
873 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
874
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
875 u = r->upstream;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
876
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
877 rc = ngx_http_parse_status_line(r, &u->buffer, status);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
878
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
879 if (rc == NGX_AGAIN) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
880 return rc;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
881 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
882
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
883 if (rc == NGX_ERROR) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
884 u->process_header = ngx_http_scgi_process_header;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
885 return ngx_http_scgi_process_header(r);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
886 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
887
5575
d15822784cf9 Upstream: fix $upstream_status variable.
Piotr Sikora <piotr@cloudflare.com>
parents: 5496
diff changeset
888 if (u->state && u->state->status == 0) {
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
889 u->state->status = status->code;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
890 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
891
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
892 u->headers_in.status_n = status->code;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
893
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
894 len = status->end - status->start;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
895 u->headers_in.status_line.len = len;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
896
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
897 u->headers_in.status_line.data = ngx_pnalloc(r->pool, len);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
898 if (u->headers_in.status_line.data == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
899 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
900 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
901
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
902 ngx_memcpy(u->headers_in.status_line.data, status->start, len);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
903
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
904 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
905 "http scgi status %ui \"%V\"",
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
906 u->headers_in.status_n, &u->headers_in.status_line);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
907
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
908 u->process_header = ngx_http_scgi_process_header;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
909
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
910 return ngx_http_scgi_process_header(r);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
911 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
912
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
913
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
914 static ngx_int_t
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
915 ngx_http_scgi_process_header(ngx_http_request_t *r)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
916 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
917 ngx_str_t *status_line;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
918 ngx_int_t rc, status;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
919 ngx_table_elt_t *h;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
920 ngx_http_upstream_t *u;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
921 ngx_http_upstream_header_t *hh;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
922 ngx_http_upstream_main_conf_t *umcf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
923
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
924 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
925
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
926 for ( ;; ) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
927
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
928 rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
929
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
930 if (rc == NGX_OK) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
931
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
932 /* a header line has been parsed successfully */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
933
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
934 h = ngx_list_push(&r->upstream->headers_in.headers);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
935 if (h == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
936 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
937 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
938
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
939 h->hash = r->header_hash;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
940
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
941 h->key.len = r->header_name_end - r->header_name_start;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
942 h->value.len = r->header_end - r->header_start;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
943
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
944 h->key.data = ngx_pnalloc(r->pool,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
945 h->key.len + 1 + h->value.len + 1
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
946 + h->key.len);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
947 if (h->key.data == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
948 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
949 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
950
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
951 h->value.data = h->key.data + h->key.len + 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
952 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
953
4529
1ebec1d15a25 Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents: 4522
diff changeset
954 ngx_memcpy(h->key.data, r->header_name_start, h->key.len);
1ebec1d15a25 Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents: 4522
diff changeset
955 h->key.data[h->key.len] = '\0';
1ebec1d15a25 Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents: 4522
diff changeset
956 ngx_memcpy(h->value.data, r->header_start, h->value.len);
1ebec1d15a25 Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents: 4522
diff changeset
957 h->value.data[h->value.len] = '\0';
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
958
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
959 if (h->key.len == r->lowcase_index) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
960 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
961
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
962 } else {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
963 ngx_strlow(h->lowcase_key, h->key.data, h->key.len);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
964 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
965
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
966 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
967 h->lowcase_key, h->key.len);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
968
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
969 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
970 return NGX_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
971 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
972
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
973 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
974 "http scgi header: \"%V: %V\"", &h->key, &h->value);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
975
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
976 continue;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
977 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
978
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
979 if (rc == NGX_HTTP_PARSE_HEADER_DONE) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
980
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
981 /* a whole header has been parsed successfully */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
982
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
983 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
984 "http scgi header done");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
985
4371
16ebad9447ee Fixed incorrect use of r->http_version in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4331
diff changeset
986 u = r->upstream;
16ebad9447ee Fixed incorrect use of r->http_version in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4331
diff changeset
987
16ebad9447ee Fixed incorrect use of r->http_version in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4331
diff changeset
988 if (u->headers_in.status_n) {
5078
10c74d3b15d1 Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5008
diff changeset
989 goto done;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
990 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
991
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
992 if (u->headers_in.status) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
993 status_line = &u->headers_in.status->value;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
994
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
995 status = ngx_atoi(status_line->data, 3);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
996 if (status == NGX_ERROR) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
997 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
998 "upstream sent invalid status \"%V\"",
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
999 status_line);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1000 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1001 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1002
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1003 u->headers_in.status_n = status;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1004 u->headers_in.status_line = *status_line;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1005
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1006 } else if (u->headers_in.location) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1007 u->headers_in.status_n = 302;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1008 ngx_str_set(&u->headers_in.status_line,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1009 "302 Moved Temporarily");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1010
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1011 } else {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1012 u->headers_in.status_n = 200;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1013 ngx_str_set(&u->headers_in.status_line, "200 OK");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1014 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1015
5575
d15822784cf9 Upstream: fix $upstream_status variable.
Piotr Sikora <piotr@cloudflare.com>
parents: 5496
diff changeset
1016 if (u->state && u->state->status == 0) {
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1017 u->state->status = u->headers_in.status_n;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1018 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1019
5078
10c74d3b15d1 Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5008
diff changeset
1020 done:
10c74d3b15d1 Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5008
diff changeset
1021
10c74d3b15d1 Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5008
diff changeset
1022 if (u->headers_in.status_n == NGX_HTTP_SWITCHING_PROTOCOLS
5080
8da37c1b22a4 Trailing whitespace fix.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5078
diff changeset
1023 && r->headers_in.upgrade)
5078
10c74d3b15d1 Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5008
diff changeset
1024 {
10c74d3b15d1 Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5008
diff changeset
1025 u->upgrade = 1;
10c74d3b15d1 Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5008
diff changeset
1026 }
10c74d3b15d1 Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5008
diff changeset
1027
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1028 return NGX_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1029 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1030
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1031 if (rc == NGX_AGAIN) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1032 return NGX_AGAIN;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1033 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1034
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1035 /* there was error while a header line parsing */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1036
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1037 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1038 "upstream sent invalid header");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1039
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1040 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1041 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1042 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1043
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1044
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1045 static void
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1046 ngx_http_scgi_abort_request(ngx_http_request_t *r)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1047 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1048 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1049 "abort http scgi request");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1050
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1051 return;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1052 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1053
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1054
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1055 static void
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1056 ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1057 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1058 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1059 "finalize http scgi request");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1060
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1061 return;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1062 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1063
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1064
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1065 static void *
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1066 ngx_http_scgi_create_loc_conf(ngx_conf_t *cf)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1067 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1068 ngx_http_scgi_loc_conf_t *conf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1069
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1070 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_scgi_loc_conf_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1071 if (conf == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1072 return NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1073 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1074
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1075 conf->upstream.store = NGX_CONF_UNSET;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1076 conf->upstream.store_access = NGX_CONF_UNSET_UINT;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1077 conf->upstream.buffering = NGX_CONF_UNSET;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1078 conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1079
5008
fd84344f1df7 Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents: 4947
diff changeset
1080 conf->upstream.local = NGX_CONF_UNSET_PTR;
fd84344f1df7 Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents: 4947
diff changeset
1081
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1082 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1083 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1084 conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1085
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1086 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1087 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1088
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1089 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1090 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1091 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1092
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1093 conf->upstream.pass_request_headers = NGX_CONF_UNSET;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1094 conf->upstream.pass_request_body = NGX_CONF_UNSET;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1095
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1096 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1097 conf->upstream.cache = NGX_CONF_UNSET_PTR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1098 conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT;
3699
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
1099 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR;
3693
e3bcc2f4c418 fix scgi_no_cache and uwsgi_no_cache initialization
Igor Sysoev <igor@sysoev.ru>
parents: 3692
diff changeset
1100 conf->upstream.no_cache = NGX_CONF_UNSET_PTR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1101 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR;
4386
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
1102 conf->upstream.cache_lock = NGX_CONF_UNSET;
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
1103 conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC;
5441
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
1104 conf->upstream.cache_revalidate = NGX_CONF_UNSET;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1105 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1106
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1107 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1108 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1109
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1110 conf->upstream.intercept_errors = NGX_CONF_UNSET;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1111
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1112 /* "scgi_cyclic_temp_file" is disabled */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1113 conf->upstream.cyclic_temp_file = 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1114
4157
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
1115 conf->upstream.change_buffering = 1;
9d59a8eda373 Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4015
diff changeset
1116
3976
215fe9223419 update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents: 3879
diff changeset
1117 ngx_str_set(&conf->upstream.module, "scgi");
215fe9223419 update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents: 3879
diff changeset
1118
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1119 return conf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1120 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1121
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1122
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1123 static char *
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1124 ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1125 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1126 ngx_http_scgi_loc_conf_t *prev = parent;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1127 ngx_http_scgi_loc_conf_t *conf = child;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1128
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1129 size_t size;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1130 ngx_hash_init_t hash;
3731
72cc5b789021 inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents: 3729
diff changeset
1131 ngx_http_core_loc_conf_t *clcf;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1132
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1133 if (conf->upstream.store != 0) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1134 ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1135
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1136 if (conf->upstream.store_lengths == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1137 conf->upstream.store_lengths = prev->upstream.store_lengths;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1138 conf->upstream.store_values = prev->upstream.store_values;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1139 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1140 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1141
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1142 ngx_conf_merge_uint_value(conf->upstream.store_access,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1143 prev->upstream.store_access, 0600);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1144
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1145 ngx_conf_merge_value(conf->upstream.buffering,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1146 prev->upstream.buffering, 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1147
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1148 ngx_conf_merge_value(conf->upstream.ignore_client_abort,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1149 prev->upstream.ignore_client_abort, 0);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1150
5008
fd84344f1df7 Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents: 4947
diff changeset
1151 ngx_conf_merge_ptr_value(conf->upstream.local,
fd84344f1df7 Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents: 4947
diff changeset
1152 prev->upstream.local, NULL);
fd84344f1df7 Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents: 4947
diff changeset
1153
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1154 ngx_conf_merge_msec_value(conf->upstream.connect_timeout,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1155 prev->upstream.connect_timeout, 60000);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1156
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1157 ngx_conf_merge_msec_value(conf->upstream.send_timeout,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1158 prev->upstream.send_timeout, 60000);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1159
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1160 ngx_conf_merge_msec_value(conf->upstream.read_timeout,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1161 prev->upstream.read_timeout, 60000);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1162
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1163 ngx_conf_merge_size_value(conf->upstream.send_lowat,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1164 prev->upstream.send_lowat, 0);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1165
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1166 ngx_conf_merge_size_value(conf->upstream.buffer_size,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1167 prev->upstream.buffer_size,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1168 (size_t) ngx_pagesize);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1169
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1170
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1171 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1172 8, ngx_pagesize);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1173
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1174 if (conf->upstream.bufs.num < 2) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1175 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1176 "there must be at least 2 \"scgi_buffers\"");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1177 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1178 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1179
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1180
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1181 size = conf->upstream.buffer_size;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1182 if (size < conf->upstream.bufs.size) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1183 size = conf->upstream.bufs.size;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1184 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1185
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1186
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1187 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1188 prev->upstream.busy_buffers_size_conf,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1189 NGX_CONF_UNSET_SIZE);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1190
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1191 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1192 conf->upstream.busy_buffers_size = 2 * size;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1193 } else {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1194 conf->upstream.busy_buffers_size =
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1195 conf->upstream.busy_buffers_size_conf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1196 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1197
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1198 if (conf->upstream.busy_buffers_size < size) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1199 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
4593
834049edae24 Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents: 4529
diff changeset
1200 "\"scgi_busy_buffers_size\" must be equal to or greater "
834049edae24 Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents: 4529
diff changeset
1201 "than the maximum of the value of \"scgi_buffer_size\" and "
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1202 "one of the \"scgi_buffers\"");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1203
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1204 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1205 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1206
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1207 if (conf->upstream.busy_buffers_size
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1208 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1209 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1210 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1211 "\"scgi_busy_buffers_size\" must be less than "
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1212 "the size of all \"scgi_buffers\" minus one buffer");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1213
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1214 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1215 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1216
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1217
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1218 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1219 prev->upstream.temp_file_write_size_conf,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1220 NGX_CONF_UNSET_SIZE);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1221
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1222 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1223 conf->upstream.temp_file_write_size = 2 * size;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1224 } else {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1225 conf->upstream.temp_file_write_size =
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1226 conf->upstream.temp_file_write_size_conf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1227 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1228
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1229 if (conf->upstream.temp_file_write_size < size) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1230 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
4593
834049edae24 Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents: 4529
diff changeset
1231 "\"scgi_temp_file_write_size\" must be equal to or greater than "
834049edae24 Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents: 4529
diff changeset
1232 "the maximum of the value of \"scgi_buffer_size\" and "
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1233 "one of the \"scgi_buffers\"");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1234
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1235 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1236 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1237
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1238
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1239 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1240 prev->upstream.max_temp_file_size_conf,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1241 NGX_CONF_UNSET_SIZE);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1242
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1243 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1244 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1245 } else {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1246 conf->upstream.max_temp_file_size =
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1247 conf->upstream.max_temp_file_size_conf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1248 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1249
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1250 if (conf->upstream.max_temp_file_size != 0
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1251 && conf->upstream.max_temp_file_size < size) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1252 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1253 "\"scgi_max_temp_file_size\" must be equal to zero to disable "
4593
834049edae24 Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents: 4529
diff changeset
1254 "temporary files usage or must be equal to or greater than "
834049edae24 Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents: 4529
diff changeset
1255 "the maximum of the value of \"scgi_buffer_size\" and "
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1256 "one of the \"scgi_buffers\"");
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1257
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1258 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1259 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1260
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1261
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1262 ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1263 prev->upstream.ignore_headers,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1264 NGX_CONF_BITMASK_SET);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1265
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1266
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1267 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1268 prev->upstream.next_upstream,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1269 (NGX_CONF_BITMASK_SET
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1270 |NGX_HTTP_UPSTREAM_FT_ERROR
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1271 |NGX_HTTP_UPSTREAM_FT_TIMEOUT));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1272
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1273 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1274 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1275 |NGX_HTTP_UPSTREAM_FT_OFF;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1276 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1277
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1278 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1279 prev->upstream.temp_path,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1280 &ngx_http_scgi_temp_path)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1281 != NGX_OK)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1282 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1283 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1284 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1285
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1286 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1287
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1288 ngx_conf_merge_ptr_value(conf->upstream.cache,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1289 prev->upstream.cache, NULL);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1290
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1291 if (conf->upstream.cache && conf->upstream.cache->data == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1292 ngx_shm_zone_t *shm_zone;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1293
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1294 shm_zone = conf->upstream.cache;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1295
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1296 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1297 "\"scgi_cache\" zone \"%V\" is unknown",
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1298 &shm_zone->shm.name);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1299
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1300 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1301 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1302
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1303 ngx_conf_merge_uint_value(conf->upstream.cache_min_uses,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1304 prev->upstream.cache_min_uses, 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1305
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1306 ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1307 prev->upstream.cache_use_stale,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1308 (NGX_CONF_BITMASK_SET
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1309 |NGX_HTTP_UPSTREAM_FT_OFF));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1310
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1311 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1312 conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1313 |NGX_HTTP_UPSTREAM_FT_OFF;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1314 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1315
4401
d45742815c90 Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4386
diff changeset
1316 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_ERROR) {
d45742815c90 Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4386
diff changeset
1317 conf->upstream.cache_use_stale |= NGX_HTTP_UPSTREAM_FT_NOLIVE;
d45742815c90 Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4386
diff changeset
1318 }
d45742815c90 Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4386
diff changeset
1319
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1320 if (conf->upstream.cache_methods == 0) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1321 conf->upstream.cache_methods = prev->upstream.cache_methods;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1322 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1323
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1324 conf->upstream.cache_methods |= NGX_HTTP_GET|NGX_HTTP_HEAD;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1325
3699
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
1326 ngx_conf_merge_ptr_value(conf->upstream.cache_bypass,
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
1327 prev->upstream.cache_bypass, NULL);
b0a0686a85bb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents: 3693
diff changeset
1328
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1329 ngx_conf_merge_ptr_value(conf->upstream.no_cache,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1330 prev->upstream.no_cache, NULL);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1331
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1332 ngx_conf_merge_ptr_value(conf->upstream.cache_valid,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1333 prev->upstream.cache_valid, NULL);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1334
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1335 if (conf->cache_key.value.data == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1336 conf->cache_key = prev->cache_key;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1337 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1338
4386
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
1339 ngx_conf_merge_value(conf->upstream.cache_lock,
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
1340 prev->upstream.cache_lock, 0);
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
1341
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
1342 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout,
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
1343 prev->upstream.cache_lock_timeout, 5000);
92deb73393f7 Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4373
diff changeset
1344
5441
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
1345 ngx_conf_merge_value(conf->upstream.cache_revalidate,
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
1346 prev->upstream.cache_revalidate, 0);
43ccaf8e8728 Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5393
diff changeset
1347
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1348 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1349
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1350 ngx_conf_merge_value(conf->upstream.pass_request_headers,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1351 prev->upstream.pass_request_headers, 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1352 ngx_conf_merge_value(conf->upstream.pass_request_body,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1353 prev->upstream.pass_request_body, 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1354
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1355 ngx_conf_merge_value(conf->upstream.intercept_errors,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1356 prev->upstream.intercept_errors, 0);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1357
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1358 hash.max_size = 512;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1359 hash.bucket_size = ngx_align(64, ngx_cacheline_size);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1360 hash.name = "scgi_hide_headers_hash";
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1361
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1362 if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
3670
2728c4e4a9ae do not use a cache headers set to hide
Igor Sysoev <igor@sysoev.ru>
parents: 3668
diff changeset
1363 &prev->upstream, ngx_http_scgi_hide_headers, &hash)
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1364 != NGX_OK)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1365 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1366 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1367 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1368
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1369 if (conf->upstream.upstream == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1370 conf->upstream.upstream = prev->upstream.upstream;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1371 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1372
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1373 if (conf->scgi_lengths == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1374 conf->scgi_lengths = prev->scgi_lengths;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1375 conf->scgi_values = prev->scgi_values;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1376 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1377
3731
72cc5b789021 inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents: 3729
diff changeset
1378 if (conf->upstream.upstream || conf->scgi_lengths) {
72cc5b789021 inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents: 3729
diff changeset
1379 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
72cc5b789021 inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents: 3729
diff changeset
1380 if (clcf->handler == NULL && clcf->lmt_excpt) {
72cc5b789021 inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents: 3729
diff changeset
1381 clcf->handler = ngx_http_scgi_handler;
72cc5b789021 inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents: 3729
diff changeset
1382 }
72cc5b789021 inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents: 3729
diff changeset
1383 }
72cc5b789021 inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents: 3729
diff changeset
1384
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1385 if (ngx_http_scgi_merge_params(cf, conf, prev) != NGX_OK) {
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1386 return NGX_CONF_ERROR;
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1387 }
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1388
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1389 return NGX_CONF_OK;
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1390 }
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1391
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1392
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1393 static ngx_int_t
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1394 ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1395 ngx_http_scgi_loc_conf_t *prev)
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1396 {
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1397 u_char *p;
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1398 size_t size;
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1399 uintptr_t *code;
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1400 ngx_uint_t i, nsrc;
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1401 ngx_array_t headers_names;
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1402 #if (NGX_HTTP_CACHE)
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1403 ngx_array_t params_merged;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1404 #endif
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1405 ngx_hash_key_t *hk;
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1406 ngx_hash_init_t hash;
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1407 ngx_http_upstream_param_t *src;
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1408 ngx_http_script_compile_t sc;
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1409 ngx_http_script_copy_code_t *copy;
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1410
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1411 if (conf->params_source == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1412 conf->params_source = prev->params_source;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1413
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1414 if (prev->headers_hash.buckets
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1415 #if (NGX_HTTP_CACHE)
4522
14411ee4d89f Whitespace fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
1416 && ((conf->upstream.cache == NULL)
14411ee4d89f Whitespace fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
1417 == (prev->upstream.cache == NULL))
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1418 #endif
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1419 )
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1420 {
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1421 conf->flushes = prev->flushes;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1422 conf->params_len = prev->params_len;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1423 conf->params = prev->params;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1424 conf->headers_hash = prev->headers_hash;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1425 conf->header_params = prev->header_params;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1426
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1427 return NGX_OK;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1428 }
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1429 }
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1430
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1431 if (conf->params_source == NULL
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1432 #if (NGX_HTTP_CACHE)
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1433 && (conf->upstream.cache == NULL)
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1434 #endif
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1435 )
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1436 {
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1437 conf->headers_hash.buckets = (void *) 1;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1438 return NGX_OK;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1439 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1440
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1441 conf->params_len = ngx_array_create(cf->pool, 64, 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1442 if (conf->params_len == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1443 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1444 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1445
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1446 conf->params = ngx_array_create(cf->pool, 512, 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1447 if (conf->params == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1448 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1449 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1450
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1451 if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1452 != NGX_OK)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1453 {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1454 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1455 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1456
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1457 if (conf->params_source) {
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1458 src = conf->params_source->elts;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1459 nsrc = conf->params_source->nelts;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1460
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1461 } else {
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1462 src = NULL;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1463 nsrc = 0;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1464 }
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1465
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1466 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1467
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1468 if (conf->upstream.cache) {
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1469 ngx_keyval_t *h;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1470 ngx_http_upstream_param_t *s;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1471
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1472 if (ngx_array_init(&params_merged, cf->temp_pool, 4,
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1473 sizeof(ngx_http_upstream_param_t))
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1474 != NGX_OK)
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1475 {
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1476 return NGX_ERROR;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1477 }
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1478
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1479 for (i = 0; i < nsrc; i++) {
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1480
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1481 s = ngx_array_push(&params_merged);
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1482 if (s == NULL) {
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1483 return NGX_ERROR;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1484 }
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1485
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1486 *s = src[i];
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1487 }
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1488
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1489 h = ngx_http_scgi_cache_headers;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1490
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1491 while (h->key.len) {
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1492
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1493 src = params_merged.elts;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1494 nsrc = params_merged.nelts;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1495
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1496 for (i = 0; i < nsrc; i++) {
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1497 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1498 goto next;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1499 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1500 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1501
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1502 s = ngx_array_push(&params_merged);
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1503 if (s == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1504 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1505 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1506
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1507 s->key = h->key;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1508 s->value = h->value;
5451
e68af4e3396f Upstream: skip empty cache headers.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5441
diff changeset
1509 s->skip_empty = 1;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1510
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1511 next:
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1512
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1513 h++;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1514 }
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1515
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1516 src = params_merged.elts;
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1517 nsrc = params_merged.nelts;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1518 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1519
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1520 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1521
4278
f57229cba7ad Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4277
diff changeset
1522 for (i = 0; i < nsrc; i++) {
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1523
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1524 if (src[i].key.len > sizeof("HTTP_") - 1
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1525 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1526 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1527 hk = ngx_array_push(&headers_names);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1528 if (hk == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1529 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1530 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1531
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1532 hk->key.len = src[i].key.len - 5;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1533 hk->key.data = src[i].key.data + 5;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1534 hk->key_hash = ngx_hash_key_lc(hk->key.data, hk->key.len);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1535 hk->value = (void *) 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1536
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1537 if (src[i].value.len == 0) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1538 continue;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1539 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1540 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1541
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1542 copy = ngx_array_push_n(conf->params_len,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1543 sizeof(ngx_http_script_copy_code_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1544 if (copy == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1545 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1546 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1547
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1548 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1549 copy->len = src[i].key.len + 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1550
4331
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1551 copy = ngx_array_push_n(conf->params_len,
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1552 sizeof(ngx_http_script_copy_code_t));
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1553 if (copy == NULL) {
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1554 return NGX_ERROR;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1555 }
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1556
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1557 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1558 copy->len = src[i].skip_empty;
059260de158d SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents: 4294
diff changeset
1559
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1560
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1561 size = (sizeof(ngx_http_script_copy_code_t)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1562 + src[i].key.len + 1 + sizeof(uintptr_t) - 1)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1563 & ~(sizeof(uintptr_t) - 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1564
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1565 copy = ngx_array_push_n(conf->params, size);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1566 if (copy == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1567 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1568 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1569
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1570 copy->code = ngx_http_script_copy_code;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1571 copy->len = src[i].key.len + 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1572
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1573 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1574 (void) ngx_cpystrn(p, src[i].key.data, src[i].key.len + 1);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1575
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1576
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1577 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1578
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1579 sc.cf = cf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1580 sc.source = &src[i].value;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1581 sc.flushes = &conf->flushes;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1582 sc.lengths = &conf->params_len;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1583 sc.values = &conf->params;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1584
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1585 if (ngx_http_script_compile(&sc) != NGX_OK) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1586 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1587 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1588
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1589 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1590 if (code == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1591 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1592 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1593
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1594 *code = (uintptr_t) NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1595
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1596
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1597 code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1598 if (code == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1599 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1600 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1601
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1602 *code = (uintptr_t) NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1603 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1604
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1605 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1606 if (code == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1607 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1608 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1609
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1610 *code = (uintptr_t) NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1611
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1612 code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1613 if (code == NULL) {
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1614 return NGX_ERROR;
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1615 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1616
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1617 *code = (uintptr_t) NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1618
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1619 conf->header_params = headers_names.nelts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1620
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1621 hash.hash = &conf->headers_hash;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1622 hash.key = ngx_hash_key_lc;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1623 hash.max_size = 512;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1624 hash.bucket_size = 64;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1625 hash.name = "scgi_params_hash";
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1626 hash.pool = cf->pool;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1627 hash.temp_pool = NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1628
4277
e4b8255e44c3 Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4157
diff changeset
1629 return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts);
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1630 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1631
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1632
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1633 static char *
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1634 ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1635 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1636 ngx_http_scgi_loc_conf_t *scf = conf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1638 ngx_url_t u;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1639 ngx_str_t *value, *url;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1640 ngx_uint_t n;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1641 ngx_http_core_loc_conf_t *clcf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1642 ngx_http_script_compile_t sc;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1643
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1644 if (scf->upstream.upstream || scf->scgi_lengths) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1645 return "is duplicate";
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1646 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1647
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1648 clcf = ngx_http_conf_get_module_loc_conf (cf, ngx_http_core_module);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1649 clcf->handler = ngx_http_scgi_handler;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1650
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1651 value = cf->args->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1652
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1653 url = &value[1];
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1654
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1655 n = ngx_http_script_variables_count(url);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1656
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1657 if (n) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1658
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1659 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1660
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1661 sc.cf = cf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1662 sc.source = url;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1663 sc.lengths = &scf->scgi_lengths;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1664 sc.values = &scf->scgi_values;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1665 sc.variables = n;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1666 sc.complete_lengths = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1667 sc.complete_values = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1668
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1669 if (ngx_http_script_compile(&sc) != NGX_OK) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1670 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1671 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1672
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1673 return NGX_CONF_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1674 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1675
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1676 ngx_memzero(&u, sizeof(ngx_url_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1677
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1678 u.url = value[1];
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1679 u.no_resolve = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1680
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1681 scf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1682 if (scf->upstream.upstream == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1683 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1684 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1685
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1686 if (clcf->name.data[clcf->name.len - 1] == '/') {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1687 clcf->auto_redirect = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1688 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1689
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1690 return NGX_CONF_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1691 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1692
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1693
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1694 static char *
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1695 ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1696 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1697 ngx_http_scgi_loc_conf_t *scf = conf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1698
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1699 ngx_str_t *value;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1700 ngx_http_script_compile_t sc;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1701
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1702 if (scf->upstream.store != NGX_CONF_UNSET || scf->upstream.store_lengths) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1703 return "is duplicate";
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1704 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1705
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1706 value = cf->args->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1707
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1708 if (ngx_strcmp(value[1].data, "off") == 0) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1709 scf->upstream.store = 0;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1710 return NGX_CONF_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1711 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1712
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1713 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1714
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1715 if (scf->upstream.cache != NGX_CONF_UNSET_PTR
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1716 && scf->upstream.cache != NULL)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1717 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1718 return "is incompatible with \"scgi_cache\"";
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1719 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1720
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1721 #endif
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1722
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1723 if (ngx_strcmp(value[1].data, "on") == 0) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1724 scf->upstream.store = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1725 return NGX_CONF_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1726 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1727
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1728 /* include the terminating '\0' into script */
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1729 value[1].len++;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1730
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1731 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1732
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1733 sc.cf = cf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1734 sc.source = &value[1];
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1735 sc.lengths = &scf->upstream.store_lengths;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1736 sc.values = &scf->upstream.store_values;
5496
9d056f10fb99 Style: removed surplus semicolons.
Valentin Bartenev <vbart@nginx.com>
parents: 5451
diff changeset
1737 sc.variables = ngx_http_script_variables_count(&value[1]);
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1738 sc.complete_lengths = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1739 sc.complete_values = 1;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1740
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1741 if (ngx_http_script_compile(&sc) != NGX_OK) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1742 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1743 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1744
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1745 return NGX_CONF_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1746 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1747
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1748
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1749 #if (NGX_HTTP_CACHE)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1750
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1751 static char *
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1752 ngx_http_scgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1753 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1754 ngx_http_scgi_loc_conf_t *scf = conf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1755
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1756 ngx_str_t *value;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1757
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1758 value = cf->args->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1759
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1760 if (scf->upstream.cache != NGX_CONF_UNSET_PTR) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1761 return "is duplicate";
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1762 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1763
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1764 if (ngx_strcmp(value[1].data, "off") == 0) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1765 scf->upstream.cache = NULL;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1766 return NGX_CONF_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1767 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1768
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1769 if (scf->upstream.store > 0 || scf->upstream.store_lengths) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1770 return "is incompatible with \"scgi_store\"";
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1771 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1772
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1773 scf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0,
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1774 &ngx_http_scgi_module);
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1775 if (scf->upstream.cache == NULL) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1776 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1777 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1778
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1779 return NGX_CONF_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1780 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1781
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1782
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1783 static char *
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1784 ngx_http_scgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1785 {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1786 ngx_http_scgi_loc_conf_t *scf = conf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1787
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1788 ngx_str_t *value;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1789 ngx_http_compile_complex_value_t ccv;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1790
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1791 value = cf->args->elts;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1792
4947
4251e72b8bb4 Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents: 4929
diff changeset
1793 if (scf->cache_key.value.data) {
3637
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1794 return "is duplicate";
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1795 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1796
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1797 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1798
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1799 ccv.cf = cf;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1800 ccv.value = &value[1];
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1801 ccv.complex_value = &scf->cache_key;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1802
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1803 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1804 return NGX_CONF_ERROR;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1805 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1806
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1807 return NGX_CONF_OK;
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1808 }
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1809
d656caa72ec9 ngx_http_scgi_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1810 #endif