nginxtra 1.6.3.9 → 1.8.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nginxtra +1 -1
  3. data/bin/nginxtra_rails +1 -1
  4. data/lib/nginxtra/version.rb +1 -1
  5. data/vendor/nginx/CHANGES +358 -14
  6. data/vendor/nginx/CHANGES.ru +372 -18
  7. data/vendor/nginx/LICENSE +2 -2
  8. data/vendor/nginx/auto/cc/clang +5 -0
  9. data/vendor/nginx/auto/cc/gcc +5 -0
  10. data/vendor/nginx/auto/lib/google-perftools/conf +1 -1
  11. data/vendor/nginx/auto/lib/openssl/make +0 -5
  12. data/vendor/nginx/auto/lib/perl/conf +9 -1
  13. data/vendor/nginx/auto/make +1 -1
  14. data/vendor/nginx/auto/modules +11 -0
  15. data/vendor/nginx/auto/options +10 -2
  16. data/vendor/nginx/auto/os/darwin +0 -1
  17. data/vendor/nginx/auto/os/freebsd +6 -23
  18. data/vendor/nginx/auto/sources +16 -14
  19. data/vendor/nginx/auto/summary +3 -24
  20. data/vendor/nginx/auto/threads +20 -0
  21. data/vendor/nginx/auto/types/sizeof +2 -12
  22. data/vendor/nginx/auto/unix +50 -6
  23. data/vendor/nginx/configure +5 -0
  24. data/vendor/nginx/contrib/vim/syntax/nginx.vim +183 -50
  25. data/vendor/nginx/src/core/nginx.c +21 -9
  26. data/vendor/nginx/src/core/nginx.h +8 -2
  27. data/vendor/nginx/src/core/ngx_buf.c +88 -0
  28. data/vendor/nginx/src/core/ngx_buf.h +15 -1
  29. data/vendor/nginx/src/core/ngx_conf_file.c +4 -1
  30. data/vendor/nginx/src/core/ngx_connection.c +25 -66
  31. data/vendor/nginx/src/core/ngx_connection.h +1 -3
  32. data/vendor/nginx/src/core/ngx_core.h +11 -3
  33. data/vendor/nginx/src/core/ngx_crypt.c +1 -1
  34. data/vendor/nginx/src/core/ngx_cycle.c +7 -1
  35. data/vendor/nginx/src/core/ngx_cycle.h +6 -2
  36. data/vendor/nginx/src/core/ngx_file.c +13 -5
  37. data/vendor/nginx/src/core/ngx_file.h +6 -0
  38. data/vendor/nginx/src/core/ngx_log.c +215 -21
  39. data/vendor/nginx/src/core/ngx_log.h +9 -1
  40. data/vendor/nginx/src/core/ngx_output_chain.c +104 -15
  41. data/vendor/nginx/src/core/ngx_palloc.c +3 -7
  42. data/vendor/nginx/src/core/ngx_rbtree.c +2 -4
  43. data/vendor/nginx/src/core/ngx_rbtree.h +2 -4
  44. data/vendor/nginx/src/core/ngx_regex.c +14 -6
  45. data/vendor/nginx/src/core/ngx_resolver.c +16 -23
  46. data/vendor/nginx/src/core/ngx_resolver.h +8 -7
  47. data/vendor/nginx/src/core/ngx_shmtx.c +1 -1
  48. data/vendor/nginx/src/core/ngx_slab.c +89 -2
  49. data/vendor/nginx/src/core/ngx_slab.h +3 -0
  50. data/vendor/nginx/src/core/ngx_string.c +58 -2
  51. data/vendor/nginx/src/core/ngx_string.h +1 -0
  52. data/vendor/nginx/src/core/ngx_syslog.c +374 -0
  53. data/vendor/nginx/src/core/ngx_syslog.h +30 -0
  54. data/vendor/nginx/src/core/ngx_thread_pool.c +630 -0
  55. data/vendor/nginx/src/core/ngx_thread_pool.h +36 -0
  56. data/vendor/nginx/src/core/ngx_times.c +19 -2
  57. data/vendor/nginx/src/core/ngx_times.h +1 -0
  58. data/vendor/nginx/src/event/modules/ngx_aio_module.c +1 -1
  59. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +9 -24
  60. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +152 -28
  61. data/vendor/nginx/src/event/modules/ngx_eventport_module.c +43 -25
  62. data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +86 -156
  63. data/vendor/nginx/src/event/modules/ngx_poll_module.c +21 -37
  64. data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +15 -27
  65. data/vendor/nginx/src/event/modules/ngx_select_module.c +10 -12
  66. data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +7 -9
  67. data/vendor/nginx/src/event/ngx_event.c +5 -33
  68. data/vendor/nginx/src/event/ngx_event.h +15 -50
  69. data/vendor/nginx/src/event/ngx_event_accept.c +11 -10
  70. data/vendor/nginx/src/event/ngx_event_connect.c +0 -11
  71. data/vendor/nginx/src/event/ngx_event_connect.h +1 -4
  72. data/vendor/nginx/src/event/ngx_event_openssl.c +622 -38
  73. data/vendor/nginx/src/event/ngx_event_openssl.h +20 -2
  74. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +5 -1
  75. data/vendor/nginx/src/event/ngx_event_pipe.c +45 -19
  76. data/vendor/nginx/src/event/ngx_event_pipe.h +3 -0
  77. data/vendor/nginx/src/event/ngx_event_posted.c +7 -145
  78. data/vendor/nginx/src/event/ngx_event_posted.h +12 -39
  79. data/vendor/nginx/src/event/ngx_event_timer.c +50 -70
  80. data/vendor/nginx/src/event/ngx_event_timer.h +2 -14
  81. data/vendor/nginx/src/http/modules/ngx_http_addition_filter_module.c +1 -1
  82. data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +416 -71
  83. data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +19 -15
  84. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +16 -4
  85. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +601 -134
  86. data/vendor/nginx/src/http/modules/ngx_http_geo_module.c +1 -1
  87. data/vendor/nginx/src/http/modules/ngx_http_geoip_module.c +9 -3
  88. data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -3
  89. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +9 -3
  90. data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +0 -2
  91. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +197 -91
  92. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -0
  93. data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +65 -162
  94. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +53 -67
  95. data/vendor/nginx/src/http/modules/ngx_http_log_module.c +128 -23
  96. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +25 -6
  97. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +1 -1
  98. data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +39 -13
  99. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +697 -141
  100. data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +5 -1
  101. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +282 -125
  102. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +4 -1
  103. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +44 -1
  104. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +2 -0
  105. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +10 -8
  106. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +18 -3
  107. data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +641 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +1 -1
  109. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +3 -21
  110. data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +0 -5
  111. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +449 -125
  112. data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +4 -2
  113. data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -1
  114. data/vendor/nginx/src/http/ngx_http.c +10 -5
  115. data/vendor/nginx/src/http/ngx_http.h +4 -4
  116. data/vendor/nginx/src/http/ngx_http_cache.h +26 -1
  117. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +109 -68
  118. data/vendor/nginx/src/http/ngx_http_core_module.c +191 -46
  119. data/vendor/nginx/src/http/ngx_http_core_module.h +16 -4
  120. data/vendor/nginx/src/http/ngx_http_file_cache.c +584 -67
  121. data/vendor/nginx/src/http/ngx_http_parse.c +55 -4
  122. data/vendor/nginx/src/http/ngx_http_request.c +14 -6
  123. data/vendor/nginx/src/http/ngx_http_request.h +12 -4
  124. data/vendor/nginx/src/http/ngx_http_request_body.c +114 -28
  125. data/vendor/nginx/src/http/ngx_http_spdy.c +383 -229
  126. data/vendor/nginx/src/http/ngx_http_spdy.h +8 -5
  127. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +12 -4
  128. data/vendor/nginx/src/http/ngx_http_special_response.c +2 -2
  129. data/vendor/nginx/src/http/ngx_http_upstream.c +808 -132
  130. data/vendor/nginx/src/http/ngx_http_upstream.h +33 -3
  131. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +72 -65
  132. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +1 -2
  133. data/vendor/nginx/src/http/ngx_http_variables.c +47 -3
  134. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +15 -6
  135. data/vendor/nginx/src/mail/ngx_mail.c +2 -3
  136. data/vendor/nginx/src/mail/ngx_mail.h +2 -0
  137. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +140 -11
  138. data/vendor/nginx/src/mail/ngx_mail_core_module.c +3 -3
  139. data/vendor/nginx/src/mail/ngx_mail_handler.c +79 -2
  140. data/vendor/nginx/src/mail/ngx_mail_imap_module.c +3 -1
  141. data/vendor/nginx/src/mail/ngx_mail_pop3_module.c +3 -1
  142. data/vendor/nginx/src/mail/ngx_mail_smtp_module.c +3 -1
  143. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +125 -1
  144. data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +8 -0
  145. data/vendor/nginx/src/misc/ngx_cpp_test_module.cpp +1 -1
  146. data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +1 -1
  147. data/vendor/nginx/src/os/unix/ngx_channel.c +0 -7
  148. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +0 -3
  149. data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +44 -208
  150. data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +25 -17
  151. data/vendor/nginx/src/os/unix/ngx_files.c +109 -0
  152. data/vendor/nginx/src/os/unix/ngx_files.h +6 -0
  153. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +0 -6
  154. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +78 -206
  155. data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +25 -14
  156. data/vendor/nginx/src/os/unix/ngx_linux_config.h +4 -1
  157. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +235 -194
  158. data/vendor/nginx/src/os/unix/ngx_os.h +25 -3
  159. data/vendor/nginx/src/os/unix/ngx_posix_init.c +4 -2
  160. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +13 -195
  161. data/vendor/nginx/src/os/unix/ngx_process_cycle.h +0 -1
  162. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +27 -108
  163. data/vendor/nginx/src/os/unix/ngx_setproctitle.h +2 -2
  164. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +12 -67
  165. data/vendor/nginx/src/os/unix/ngx_thread.h +26 -83
  166. data/vendor/nginx/src/os/unix/ngx_thread_cond.c +87 -0
  167. data/vendor/nginx/src/os/unix/ngx_thread_id.c +70 -0
  168. data/vendor/nginx/src/os/unix/ngx_thread_mutex.c +174 -0
  169. data/vendor/nginx/src/os/unix/ngx_user.c +2 -20
  170. data/vendor/nginx/src/os/unix/ngx_writev_chain.c +129 -98
  171. metadata +16 -17
  172. data/vendor/nginx/auto/lib/zlib/patch.zlib.h +0 -10
  173. data/vendor/nginx/src/event/ngx_event_busy_lock.c +0 -286
  174. data/vendor/nginx/src/event/ngx_event_busy_lock.h +0 -65
  175. data/vendor/nginx/src/event/ngx_event_mutex.c +0 -70
  176. data/vendor/nginx/src/http/ngx_http_busy_lock.c +0 -307
  177. data/vendor/nginx/src/http/ngx_http_busy_lock.h +0 -54
  178. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +0 -756
  179. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +0 -122
  180. data/vendor/nginx/src/os/unix/ngx_pthread_thread.c +0 -278
  181. data/vendor/nginx/src/os/unix/rfork_thread.S +0 -73
@@ -930,7 +930,11 @@ ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
930
930
  if (v->get_handler == NULL
931
931
  && ngx_strncasecmp(value[1].data, (u_char *) "http_", 5) != 0
932
932
  && ngx_strncasecmp(value[1].data, (u_char *) "sent_http_", 10) != 0
933
- && ngx_strncasecmp(value[1].data, (u_char *) "upstream_http_", 14) != 0)
933
+ && ngx_strncasecmp(value[1].data, (u_char *) "upstream_http_", 14) != 0
934
+ && ngx_strncasecmp(value[1].data, (u_char *) "cookie_", 7) != 0
935
+ && ngx_strncasecmp(value[1].data, (u_char *) "upstream_cookie_", 16)
936
+ != 0
937
+ && ngx_strncasecmp(value[1].data, (u_char *) "arg_", 4) != 0)
934
938
  {
935
939
  v->get_handler = ngx_http_rewrite_var;
936
940
  v->data = index;
@@ -12,15 +12,27 @@
12
12
 
13
13
 
14
14
  typedef struct {
15
- ngx_http_upstream_conf_t upstream;
15
+ ngx_array_t caches; /* ngx_http_file_cache_t * */
16
+ } ngx_http_scgi_main_conf_t;
17
+
16
18
 
19
+ typedef struct {
17
20
  ngx_array_t *flushes;
18
- ngx_array_t *params_len;
19
- ngx_array_t *params;
20
- ngx_array_t *params_source;
21
+ ngx_array_t *lengths;
22
+ ngx_array_t *values;
23
+ ngx_uint_t number;
24
+ ngx_hash_t hash;
25
+ } ngx_http_scgi_params_t;
26
+
21
27
 
22
- ngx_hash_t headers_hash;
23
- ngx_uint_t header_params;
28
+ typedef struct {
29
+ ngx_http_upstream_conf_t upstream;
30
+
31
+ ngx_http_scgi_params_t params;
32
+ #if (NGX_HTTP_CACHE)
33
+ ngx_http_scgi_params_t params_cache;
34
+ #endif
35
+ ngx_array_t *params_source;
24
36
 
25
37
  ngx_array_t *scgi_lengths;
26
38
  ngx_array_t *scgi_values;
@@ -40,11 +52,13 @@ static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r);
40
52
  static void ngx_http_scgi_abort_request(ngx_http_request_t *r);
41
53
  static void ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc);
42
54
 
55
+ static void *ngx_http_scgi_create_main_conf(ngx_conf_t *cf);
43
56
  static void *ngx_http_scgi_create_loc_conf(ngx_conf_t *cf);
44
57
  static char *ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
45
58
  void *child);
46
- static ngx_int_t ngx_http_scgi_merge_params(ngx_conf_t *cf,
47
- ngx_http_scgi_loc_conf_t *conf, ngx_http_scgi_loc_conf_t *prev);
59
+ static ngx_int_t ngx_http_scgi_init_params(ngx_conf_t *cf,
60
+ ngx_http_scgi_loc_conf_t *conf, ngx_http_scgi_params_t *params,
61
+ ngx_keyval_t *default_params);
48
62
 
49
63
  static char *ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
50
64
  static char *ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd,
@@ -106,6 +120,13 @@ static ngx_command_t ngx_http_scgi_commands[] = {
106
120
  offsetof(ngx_http_scgi_loc_conf_t, upstream.buffering),
107
121
  NULL },
108
122
 
123
+ { ngx_string("scgi_request_buffering"),
124
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
125
+ ngx_conf_set_flag_slot,
126
+ NGX_HTTP_LOC_CONF_OFFSET,
127
+ offsetof(ngx_http_scgi_loc_conf_t, upstream.request_buffering),
128
+ NULL },
129
+
109
130
  { ngx_string("scgi_ignore_client_abort"),
110
131
  NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
111
132
  ngx_conf_set_flag_slot,
@@ -183,6 +204,20 @@ static ngx_command_t ngx_http_scgi_commands[] = {
183
204
  offsetof(ngx_http_scgi_loc_conf_t, upstream.busy_buffers_size_conf),
184
205
  NULL },
185
206
 
207
+ { ngx_string("scgi_force_ranges"),
208
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
209
+ ngx_conf_set_flag_slot,
210
+ NGX_HTTP_LOC_CONF_OFFSET,
211
+ offsetof(ngx_http_scgi_loc_conf_t, upstream.force_ranges),
212
+ NULL },
213
+
214
+ { ngx_string("scgi_limit_rate"),
215
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
216
+ ngx_conf_set_size_slot,
217
+ NGX_HTTP_LOC_CONF_OFFSET,
218
+ offsetof(ngx_http_scgi_loc_conf_t, upstream.limit_rate),
219
+ NULL },
220
+
186
221
  #if (NGX_HTTP_CACHE)
187
222
 
188
223
  { ngx_string("scgi_cache"),
@@ -202,8 +237,8 @@ static ngx_command_t ngx_http_scgi_commands[] = {
202
237
  { ngx_string("scgi_cache_path"),
203
238
  NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE,
204
239
  ngx_http_file_cache_set_slot,
205
- 0,
206
- 0,
240
+ NGX_HTTP_MAIN_CONF_OFFSET,
241
+ offsetof(ngx_http_scgi_main_conf_t, caches),
207
242
  &ngx_http_scgi_module },
208
243
 
209
244
  { ngx_string("scgi_cache_bypass"),
@@ -262,6 +297,13 @@ static ngx_command_t ngx_http_scgi_commands[] = {
262
297
  offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock_timeout),
263
298
  NULL },
264
299
 
300
+ { ngx_string("scgi_cache_lock_age"),
301
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
302
+ ngx_conf_set_msec_slot,
303
+ NGX_HTTP_LOC_CONF_OFFSET,
304
+ offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock_age),
305
+ NULL },
306
+
265
307
  { ngx_string("scgi_cache_revalidate"),
266
308
  NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
267
309
  ngx_conf_set_flag_slot,
@@ -299,6 +341,20 @@ static ngx_command_t ngx_http_scgi_commands[] = {
299
341
  offsetof(ngx_http_scgi_loc_conf_t, upstream.next_upstream),
300
342
  &ngx_http_scgi_next_upstream_masks },
301
343
 
344
+ { ngx_string("scgi_next_upstream_tries"),
345
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
346
+ ngx_conf_set_num_slot,
347
+ NGX_HTTP_LOC_CONF_OFFSET,
348
+ offsetof(ngx_http_scgi_loc_conf_t, upstream.next_upstream_tries),
349
+ NULL },
350
+
351
+ { ngx_string("scgi_next_upstream_timeout"),
352
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
353
+ ngx_conf_set_msec_slot,
354
+ NGX_HTTP_LOC_CONF_OFFSET,
355
+ offsetof(ngx_http_scgi_loc_conf_t, upstream.next_upstream_timeout),
356
+ NULL },
357
+
302
358
  { ngx_string("scgi_param"),
303
359
  NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23,
304
360
  ngx_http_upstream_param_set_slot,
@@ -335,7 +391,7 @@ static ngx_http_module_t ngx_http_scgi_module_ctx = {
335
391
  NULL, /* preconfiguration */
336
392
  NULL, /* postconfiguration */
337
393
 
338
- NULL, /* create main configuration */
394
+ ngx_http_scgi_create_main_conf, /* create main configuration */
339
395
  NULL, /* init main configuration */
340
396
 
341
397
  NULL, /* create server configuration */
@@ -379,7 +435,7 @@ static ngx_keyval_t ngx_http_scgi_cache_headers[] = {
379
435
  { ngx_string("HTTP_IF_MODIFIED_SINCE"),
380
436
  ngx_string("$upstream_cache_last_modified") },
381
437
  { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") },
382
- { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") },
438
+ { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("$upstream_cache_etag") },
383
439
  { ngx_string("HTTP_IF_MATCH"), ngx_string("") },
384
440
  { ngx_string("HTTP_RANGE"), ngx_string("") },
385
441
  { ngx_string("HTTP_IF_RANGE"), ngx_string("") },
@@ -397,10 +453,13 @@ static ngx_path_init_t ngx_http_scgi_temp_path = {
397
453
  static ngx_int_t
398
454
  ngx_http_scgi_handler(ngx_http_request_t *r)
399
455
  {
400
- ngx_int_t rc;
401
- ngx_http_status_t *status;
402
- ngx_http_upstream_t *u;
403
- ngx_http_scgi_loc_conf_t *scf;
456
+ ngx_int_t rc;
457
+ ngx_http_status_t *status;
458
+ ngx_http_upstream_t *u;
459
+ ngx_http_scgi_loc_conf_t *scf;
460
+ #if (NGX_HTTP_CACHE)
461
+ ngx_http_scgi_main_conf_t *smcf;
462
+ #endif
404
463
 
405
464
  if (ngx_http_upstream_create(r) != NGX_OK) {
406
465
  return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -429,8 +488,12 @@ ngx_http_scgi_handler(ngx_http_request_t *r)
429
488
  u->conf = &scf->upstream;
430
489
 
431
490
  #if (NGX_HTTP_CACHE)
491
+ smcf = ngx_http_get_module_main_conf(r, ngx_http_scgi_module);
492
+
493
+ u->caches = &smcf->caches;
432
494
  u->create_key = ngx_http_scgi_create_key;
433
495
  #endif
496
+
434
497
  u->create_request = ngx_http_scgi_create_request;
435
498
  u->reinit_request = ngx_http_scgi_reinit_request;
436
499
  u->process_header = ngx_http_scgi_process_status_line;
@@ -448,6 +511,13 @@ ngx_http_scgi_handler(ngx_http_request_t *r)
448
511
  u->pipe->input_filter = ngx_event_pipe_copy_input_filter;
449
512
  u->pipe->input_ctx = r;
450
513
 
514
+ if (!scf->upstream.request_buffering
515
+ && scf->upstream.pass_request_body
516
+ && !r->headers_in.chunked)
517
+ {
518
+ r->request_body_no_buffering = 1;
519
+ }
520
+
451
521
  rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init);
452
522
 
453
523
  if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
@@ -544,6 +614,7 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
544
614
  ngx_chain_t *cl, *body;
545
615
  ngx_list_part_t *part;
546
616
  ngx_table_elt_t *header, **ignored;
617
+ ngx_http_scgi_params_t *params;
547
618
  ngx_http_script_code_pt code;
548
619
  ngx_http_script_engine_t e, le;
549
620
  ngx_http_scgi_loc_conf_t *scf;
@@ -568,13 +639,19 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
568
639
 
569
640
  scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module);
570
641
 
571
- if (scf->params_len) {
642
+ #if (NGX_HTTP_CACHE)
643
+ params = r->upstream->cacheable ? &scf->params_cache : &scf->params;
644
+ #else
645
+ params = &scf->params;
646
+ #endif
647
+
648
+ if (params->lengths) {
572
649
  ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
573
650
 
574
- ngx_http_script_flush_no_cacheable_variables(r, scf->flushes);
651
+ ngx_http_script_flush_no_cacheable_variables(r, params->flushes);
575
652
  le.flushed = 1;
576
653
 
577
- le.ip = scf->params_len->elts;
654
+ le.ip = params->lengths->elts;
578
655
  le.request = r;
579
656
 
580
657
  while (*(uintptr_t *) le.ip) {
@@ -603,7 +680,7 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
603
680
  allocated = 0;
604
681
  lowcase_key = NULL;
605
682
 
606
- if (scf->header_params) {
683
+ if (params->number) {
607
684
  n = 0;
608
685
  part = &r->headers_in.headers.part;
609
686
 
@@ -633,7 +710,7 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
633
710
  i = 0;
634
711
  }
635
712
 
636
- if (scf->header_params) {
713
+ if (params->number) {
637
714
  if (allocated < header[i].key.len) {
638
715
  allocated = header[i].key.len + 16;
639
716
  lowcase_key = ngx_pnalloc(r->pool, allocated);
@@ -658,7 +735,7 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
658
735
  lowcase_key[n] = ch;
659
736
  }
660
737
 
661
- if (ngx_hash_find(&scf->headers_hash, hash, lowcase_key, n)) {
738
+ if (ngx_hash_find(&params->hash, hash, lowcase_key, n)) {
662
739
  ignored[header_params++] = &header[i];
663
740
  continue;
664
741
  }
@@ -686,15 +763,15 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
686
763
  b->last = ngx_sprintf(b->last, "%ui:CONTENT_LENGTH%Z%V%Z",
687
764
  len, &content_length);
688
765
 
689
- if (scf->params_len) {
766
+ if (params->lengths) {
690
767
  ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
691
768
 
692
- e.ip = scf->params->elts;
769
+ e.ip = params->values->elts;
693
770
  e.pos = b->last;
694
771
  e.request = r;
695
772
  e.flushed = 1;
696
773
 
697
- le.ip = scf->params_len->elts;
774
+ le.ip = params->lengths->elts;
698
775
 
699
776
  while (*(uintptr_t *) le.ip) {
700
777
 
@@ -802,7 +879,10 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
802
879
 
803
880
  *b->last++ = (u_char) ',';
804
881
 
805
- if (scf->upstream.pass_request_body) {
882
+ if (r->request_body_no_buffering) {
883
+ r->upstream->request_bufs = cl;
884
+
885
+ } else if (scf->upstream.pass_request_body) {
806
886
  body = r->upstream->request_bufs;
807
887
  r->upstream->request_bufs = cl;
808
888
 
@@ -1062,6 +1142,29 @@ ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
1062
1142
  }
1063
1143
 
1064
1144
 
1145
+ static void *
1146
+ ngx_http_scgi_create_main_conf(ngx_conf_t *cf)
1147
+ {
1148
+ ngx_http_scgi_main_conf_t *conf;
1149
+
1150
+ conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_scgi_main_conf_t));
1151
+ if (conf == NULL) {
1152
+ return NULL;
1153
+ }
1154
+
1155
+ #if (NGX_HTTP_CACHE)
1156
+ if (ngx_array_init(&conf->caches, cf->pool, 4,
1157
+ sizeof(ngx_http_file_cache_t *))
1158
+ != NGX_OK)
1159
+ {
1160
+ return NULL;
1161
+ }
1162
+ #endif
1163
+
1164
+ return conf;
1165
+ }
1166
+
1167
+
1065
1168
  static void *
1066
1169
  ngx_http_scgi_create_loc_conf(ngx_conf_t *cf)
1067
1170
  {
@@ -1074,17 +1177,22 @@ ngx_http_scgi_create_loc_conf(ngx_conf_t *cf)
1074
1177
 
1075
1178
  conf->upstream.store = NGX_CONF_UNSET;
1076
1179
  conf->upstream.store_access = NGX_CONF_UNSET_UINT;
1180
+ conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;
1077
1181
  conf->upstream.buffering = NGX_CONF_UNSET;
1182
+ conf->upstream.request_buffering = NGX_CONF_UNSET;
1078
1183
  conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
1184
+ conf->upstream.force_ranges = NGX_CONF_UNSET;
1079
1185
 
1080
1186
  conf->upstream.local = NGX_CONF_UNSET_PTR;
1081
1187
 
1082
1188
  conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
1083
1189
  conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC;
1084
1190
  conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC;
1191
+ conf->upstream.next_upstream_timeout = NGX_CONF_UNSET_MSEC;
1085
1192
 
1086
1193
  conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE;
1087
1194
  conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE;
1195
+ conf->upstream.limit_rate = NGX_CONF_UNSET_SIZE;
1088
1196
 
1089
1197
  conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
1090
1198
  conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
@@ -1094,13 +1202,14 @@ ngx_http_scgi_create_loc_conf(ngx_conf_t *cf)
1094
1202
  conf->upstream.pass_request_body = NGX_CONF_UNSET;
1095
1203
 
1096
1204
  #if (NGX_HTTP_CACHE)
1097
- conf->upstream.cache = NGX_CONF_UNSET_PTR;
1205
+ conf->upstream.cache = NGX_CONF_UNSET;
1098
1206
  conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT;
1099
1207
  conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR;
1100
1208
  conf->upstream.no_cache = NGX_CONF_UNSET_PTR;
1101
1209
  conf->upstream.cache_valid = NGX_CONF_UNSET_PTR;
1102
1210
  conf->upstream.cache_lock = NGX_CONF_UNSET;
1103
1211
  conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC;
1212
+ conf->upstream.cache_lock_age = NGX_CONF_UNSET_MSEC;
1104
1213
  conf->upstream.cache_revalidate = NGX_CONF_UNSET;
1105
1214
  #endif
1106
1215
 
@@ -1127,27 +1236,47 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1127
1236
  ngx_http_scgi_loc_conf_t *conf = child;
1128
1237
 
1129
1238
  size_t size;
1239
+ ngx_int_t rc;
1130
1240
  ngx_hash_init_t hash;
1131
1241
  ngx_http_core_loc_conf_t *clcf;
1132
1242
 
1133
- if (conf->upstream.store != 0) {
1243
+ #if (NGX_HTTP_CACHE)
1244
+
1245
+ if (conf->upstream.store > 0) {
1246
+ conf->upstream.cache = 0;
1247
+ }
1248
+
1249
+ if (conf->upstream.cache > 0) {
1250
+ conf->upstream.store = 0;
1251
+ }
1252
+
1253
+ #endif
1254
+
1255
+ if (conf->upstream.store == NGX_CONF_UNSET) {
1134
1256
  ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
1135
1257
 
1136
- if (conf->upstream.store_lengths == NULL) {
1137
- conf->upstream.store_lengths = prev->upstream.store_lengths;
1138
- conf->upstream.store_values = prev->upstream.store_values;
1139
- }
1258
+ conf->upstream.store_lengths = prev->upstream.store_lengths;
1259
+ conf->upstream.store_values = prev->upstream.store_values;
1140
1260
  }
1141
1261
 
1142
1262
  ngx_conf_merge_uint_value(conf->upstream.store_access,
1143
1263
  prev->upstream.store_access, 0600);
1144
1264
 
1265
+ ngx_conf_merge_uint_value(conf->upstream.next_upstream_tries,
1266
+ prev->upstream.next_upstream_tries, 0);
1267
+
1145
1268
  ngx_conf_merge_value(conf->upstream.buffering,
1146
1269
  prev->upstream.buffering, 1);
1147
1270
 
1271
+ ngx_conf_merge_value(conf->upstream.request_buffering,
1272
+ prev->upstream.request_buffering, 1);
1273
+
1148
1274
  ngx_conf_merge_value(conf->upstream.ignore_client_abort,
1149
1275
  prev->upstream.ignore_client_abort, 0);
1150
1276
 
1277
+ ngx_conf_merge_value(conf->upstream.force_ranges,
1278
+ prev->upstream.force_ranges, 0);
1279
+
1151
1280
  ngx_conf_merge_ptr_value(conf->upstream.local,
1152
1281
  prev->upstream.local, NULL);
1153
1282
 
@@ -1160,6 +1289,9 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1160
1289
  ngx_conf_merge_msec_value(conf->upstream.read_timeout,
1161
1290
  prev->upstream.read_timeout, 60000);
1162
1291
 
1292
+ ngx_conf_merge_msec_value(conf->upstream.next_upstream_timeout,
1293
+ prev->upstream.next_upstream_timeout, 0);
1294
+
1163
1295
  ngx_conf_merge_size_value(conf->upstream.send_lowat,
1164
1296
  prev->upstream.send_lowat, 0);
1165
1297
 
@@ -1167,6 +1299,9 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1167
1299
  prev->upstream.buffer_size,
1168
1300
  (size_t) ngx_pagesize);
1169
1301
 
1302
+ ngx_conf_merge_size_value(conf->upstream.limit_rate,
1303
+ prev->upstream.limit_rate, 0);
1304
+
1170
1305
 
1171
1306
  ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,
1172
1307
  8, ngx_pagesize);
@@ -1248,7 +1383,8 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1248
1383
  }
1249
1384
 
1250
1385
  if (conf->upstream.max_temp_file_size != 0
1251
- && conf->upstream.max_temp_file_size < size) {
1386
+ && conf->upstream.max_temp_file_size < size)
1387
+ {
1252
1388
  ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1253
1389
  "\"scgi_max_temp_file_size\" must be equal to zero to disable "
1254
1390
  "temporary files usage or must be equal to or greater than "
@@ -1285,13 +1421,18 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1285
1421
 
1286
1422
  #if (NGX_HTTP_CACHE)
1287
1423
 
1288
- ngx_conf_merge_ptr_value(conf->upstream.cache,
1289
- prev->upstream.cache, NULL);
1424
+ if (conf->upstream.cache == NGX_CONF_UNSET) {
1425
+ ngx_conf_merge_value(conf->upstream.cache,
1426
+ prev->upstream.cache, 0);
1290
1427
 
1291
- if (conf->upstream.cache && conf->upstream.cache->data == NULL) {
1428
+ conf->upstream.cache_zone = prev->upstream.cache_zone;
1429
+ conf->upstream.cache_value = prev->upstream.cache_value;
1430
+ }
1431
+
1432
+ if (conf->upstream.cache_zone && conf->upstream.cache_zone->data == NULL) {
1292
1433
  ngx_shm_zone_t *shm_zone;
1293
1434
 
1294
- shm_zone = conf->upstream.cache;
1435
+ shm_zone = conf->upstream.cache_zone;
1295
1436
 
1296
1437
  ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1297
1438
  "\"scgi_cache\" zone \"%V\" is unknown",
@@ -1336,12 +1477,20 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1336
1477
  conf->cache_key = prev->cache_key;
1337
1478
  }
1338
1479
 
1480
+ if (conf->upstream.cache && conf->cache_key.value.data == NULL) {
1481
+ ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
1482
+ "no \"scgi_cache_key\" for \"scgi_cache\"");
1483
+ }
1484
+
1339
1485
  ngx_conf_merge_value(conf->upstream.cache_lock,
1340
1486
  prev->upstream.cache_lock, 0);
1341
1487
 
1342
1488
  ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout,
1343
1489
  prev->upstream.cache_lock_timeout, 5000);
1344
1490
 
1491
+ ngx_conf_merge_msec_value(conf->upstream.cache_lock_age,
1492
+ prev->upstream.cache_lock_age, 5000);
1493
+
1345
1494
  ngx_conf_merge_value(conf->upstream.cache_revalidate,
1346
1495
  prev->upstream.cache_revalidate, 0);
1347
1496
 
@@ -1366,85 +1515,83 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1366
1515
  return NGX_CONF_ERROR;
1367
1516
  }
1368
1517
 
1369
- if (conf->upstream.upstream == NULL) {
1370
- conf->upstream.upstream = prev->upstream.upstream;
1371
- }
1518
+ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1372
1519
 
1373
- if (conf->scgi_lengths == NULL) {
1520
+ if (clcf->noname
1521
+ && conf->upstream.upstream == NULL && conf->scgi_lengths == NULL)
1522
+ {
1523
+ conf->upstream.upstream = prev->upstream.upstream;
1374
1524
  conf->scgi_lengths = prev->scgi_lengths;
1375
1525
  conf->scgi_values = prev->scgi_values;
1376
1526
  }
1377
1527
 
1378
- if (conf->upstream.upstream || conf->scgi_lengths) {
1379
- clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1380
- if (clcf->handler == NULL && clcf->lmt_excpt) {
1381
- clcf->handler = ngx_http_scgi_handler;
1382
- }
1528
+ if (clcf->lmt_excpt && clcf->handler == NULL
1529
+ && (conf->upstream.upstream || conf->scgi_lengths))
1530
+ {
1531
+ clcf->handler = ngx_http_scgi_handler;
1532
+ }
1533
+
1534
+ if (conf->params_source == NULL) {
1535
+ conf->params = prev->params;
1536
+ #if (NGX_HTTP_CACHE)
1537
+ conf->params_cache = prev->params_cache;
1538
+ #endif
1539
+ conf->params_source = prev->params_source;
1383
1540
  }
1384
1541
 
1385
- if (ngx_http_scgi_merge_params(cf, conf, prev) != NGX_OK) {
1542
+ rc = ngx_http_scgi_init_params(cf, conf, &conf->params, NULL);
1543
+ if (rc != NGX_OK) {
1386
1544
  return NGX_CONF_ERROR;
1387
1545
  }
1388
1546
 
1547
+ #if (NGX_HTTP_CACHE)
1548
+
1549
+ if (conf->upstream.cache) {
1550
+ rc = ngx_http_scgi_init_params(cf, conf, &conf->params_cache,
1551
+ ngx_http_scgi_cache_headers);
1552
+ if (rc != NGX_OK) {
1553
+ return NGX_CONF_ERROR;
1554
+ }
1555
+ }
1556
+
1557
+ #endif
1558
+
1389
1559
  return NGX_CONF_OK;
1390
1560
  }
1391
1561
 
1392
1562
 
1393
1563
  static ngx_int_t
1394
- ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1395
- ngx_http_scgi_loc_conf_t *prev)
1564
+ ngx_http_scgi_init_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1565
+ ngx_http_scgi_params_t *params, ngx_keyval_t *default_params)
1396
1566
  {
1397
1567
  u_char *p;
1398
1568
  size_t size;
1399
1569
  uintptr_t *code;
1400
1570
  ngx_uint_t i, nsrc;
1401
- ngx_array_t headers_names;
1402
- #if (NGX_HTTP_CACHE)
1403
- ngx_array_t params_merged;
1404
- #endif
1571
+ ngx_array_t headers_names, params_merged;
1572
+ ngx_keyval_t *h;
1405
1573
  ngx_hash_key_t *hk;
1406
1574
  ngx_hash_init_t hash;
1407
- ngx_http_upstream_param_t *src;
1575
+ ngx_http_upstream_param_t *src, *s;
1408
1576
  ngx_http_script_compile_t sc;
1409
1577
  ngx_http_script_copy_code_t *copy;
1410
1578
 
1411
- if (conf->params_source == NULL) {
1412
- conf->params_source = prev->params_source;
1413
-
1414
- if (prev->headers_hash.buckets
1415
- #if (NGX_HTTP_CACHE)
1416
- && ((conf->upstream.cache == NULL)
1417
- == (prev->upstream.cache == NULL))
1418
- #endif
1419
- )
1420
- {
1421
- conf->flushes = prev->flushes;
1422
- conf->params_len = prev->params_len;
1423
- conf->params = prev->params;
1424
- conf->headers_hash = prev->headers_hash;
1425
- conf->header_params = prev->header_params;
1426
-
1427
- return NGX_OK;
1428
- }
1579
+ if (params->hash.buckets) {
1580
+ return NGX_OK;
1429
1581
  }
1430
1582
 
1431
- if (conf->params_source == NULL
1432
- #if (NGX_HTTP_CACHE)
1433
- && (conf->upstream.cache == NULL)
1434
- #endif
1435
- )
1436
- {
1437
- conf->headers_hash.buckets = (void *) 1;
1583
+ if (conf->params_source == NULL && default_params == NULL) {
1584
+ params->hash.buckets = (void *) 1;
1438
1585
  return NGX_OK;
1439
1586
  }
1440
1587
 
1441
- conf->params_len = ngx_array_create(cf->pool, 64, 1);
1442
- if (conf->params_len == NULL) {
1588
+ params->lengths = ngx_array_create(cf->pool, 64, 1);
1589
+ if (params->lengths == NULL) {
1443
1590
  return NGX_ERROR;
1444
1591
  }
1445
1592
 
1446
- conf->params = ngx_array_create(cf->pool, 512, 1);
1447
- if (conf->params == NULL) {
1593
+ params->values = ngx_array_create(cf->pool, 512, 1);
1594
+ if (params->values == NULL) {
1448
1595
  return NGX_ERROR;
1449
1596
  }
1450
1597
 
@@ -1463,12 +1610,7 @@ ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1463
1610
  nsrc = 0;
1464
1611
  }
1465
1612
 
1466
- #if (NGX_HTTP_CACHE)
1467
-
1468
- if (conf->upstream.cache) {
1469
- ngx_keyval_t *h;
1470
- ngx_http_upstream_param_t *s;
1471
-
1613
+ if (default_params) {
1472
1614
  if (ngx_array_init(&params_merged, cf->temp_pool, 4,
1473
1615
  sizeof(ngx_http_upstream_param_t))
1474
1616
  != NGX_OK)
@@ -1486,7 +1628,7 @@ ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1486
1628
  *s = src[i];
1487
1629
  }
1488
1630
 
1489
- h = ngx_http_scgi_cache_headers;
1631
+ h = default_params;
1490
1632
 
1491
1633
  while (h->key.len) {
1492
1634
 
@@ -1517,8 +1659,6 @@ ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1517
1659
  nsrc = params_merged.nelts;
1518
1660
  }
1519
1661
 
1520
- #endif
1521
-
1522
1662
  for (i = 0; i < nsrc; i++) {
1523
1663
 
1524
1664
  if (src[i].key.len > sizeof("HTTP_") - 1
@@ -1539,7 +1679,7 @@ ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1539
1679
  }
1540
1680
  }
1541
1681
 
1542
- copy = ngx_array_push_n(conf->params_len,
1682
+ copy = ngx_array_push_n(params->lengths,
1543
1683
  sizeof(ngx_http_script_copy_code_t));
1544
1684
  if (copy == NULL) {
1545
1685
  return NGX_ERROR;
@@ -1548,7 +1688,7 @@ ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1548
1688
  copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
1549
1689
  copy->len = src[i].key.len + 1;
1550
1690
 
1551
- copy = ngx_array_push_n(conf->params_len,
1691
+ copy = ngx_array_push_n(params->lengths,
1552
1692
  sizeof(ngx_http_script_copy_code_t));
1553
1693
  if (copy == NULL) {
1554
1694
  return NGX_ERROR;
@@ -1562,7 +1702,7 @@ ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1562
1702
  + src[i].key.len + 1 + sizeof(uintptr_t) - 1)
1563
1703
  & ~(sizeof(uintptr_t) - 1);
1564
1704
 
1565
- copy = ngx_array_push_n(conf->params, size);
1705
+ copy = ngx_array_push_n(params->values, size);
1566
1706
  if (copy == NULL) {
1567
1707
  return NGX_ERROR;
1568
1708
  }
@@ -1578,15 +1718,15 @@ ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1578
1718
 
1579
1719
  sc.cf = cf;
1580
1720
  sc.source = &src[i].value;
1581
- sc.flushes = &conf->flushes;
1582
- sc.lengths = &conf->params_len;
1583
- sc.values = &conf->params;
1721
+ sc.flushes = &params->flushes;
1722
+ sc.lengths = &params->lengths;
1723
+ sc.values = &params->values;
1584
1724
 
1585
1725
  if (ngx_http_script_compile(&sc) != NGX_OK) {
1586
1726
  return NGX_ERROR;
1587
1727
  }
1588
1728
 
1589
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
1729
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
1590
1730
  if (code == NULL) {
1591
1731
  return NGX_ERROR;
1592
1732
  }
@@ -1594,7 +1734,7 @@ ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1594
1734
  *code = (uintptr_t) NULL;
1595
1735
 
1596
1736
 
1597
- code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
1737
+ code = ngx_array_push_n(params->values, sizeof(uintptr_t));
1598
1738
  if (code == NULL) {
1599
1739
  return NGX_ERROR;
1600
1740
  }
@@ -1602,23 +1742,16 @@ ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
1602
1742
  *code = (uintptr_t) NULL;
1603
1743
  }
1604
1744
 
1605
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
1745
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
1606
1746
  if (code == NULL) {
1607
1747
  return NGX_ERROR;
1608
1748
  }
1609
1749
 
1610
1750
  *code = (uintptr_t) NULL;
1611
1751
 
1612
- code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
1613
- if (code == NULL) {
1614
- return NGX_ERROR;
1615
- }
1616
-
1617
- *code = (uintptr_t) NULL;
1752
+ params->number = headers_names.nelts;
1618
1753
 
1619
- conf->header_params = headers_names.nelts;
1620
-
1621
- hash.hash = &conf->headers_hash;
1754
+ hash.hash = &params->hash;
1622
1755
  hash.key = ngx_hash_key_lc;
1623
1756
  hash.max_size = 512;
1624
1757
  hash.bucket_size = 64;
@@ -1645,7 +1778,7 @@ ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1645
1778
  return "is duplicate";
1646
1779
  }
1647
1780
 
1648
- clcf = ngx_http_conf_get_module_loc_conf (cf, ngx_http_core_module);
1781
+ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1649
1782
  clcf->handler = ngx_http_scgi_handler;
1650
1783
 
1651
1784
  value = cf->args->elts;
@@ -1699,7 +1832,7 @@ ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1699
1832
  ngx_str_t *value;
1700
1833
  ngx_http_script_compile_t sc;
1701
1834
 
1702
- if (scf->upstream.store != NGX_CONF_UNSET || scf->upstream.store_lengths) {
1835
+ if (scf->upstream.store != NGX_CONF_UNSET) {
1703
1836
  return "is duplicate";
1704
1837
  }
1705
1838
 
@@ -1711,17 +1844,14 @@ ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1711
1844
  }
1712
1845
 
1713
1846
  #if (NGX_HTTP_CACHE)
1714
-
1715
- if (scf->upstream.cache != NGX_CONF_UNSET_PTR
1716
- && scf->upstream.cache != NULL)
1717
- {
1847
+ if (scf->upstream.cache > 0) {
1718
1848
  return "is incompatible with \"scgi_cache\"";
1719
1849
  }
1720
-
1721
1850
  #endif
1722
1851
 
1852
+ scf->upstream.store = 1;
1853
+
1723
1854
  if (ngx_strcmp(value[1].data, "on") == 0) {
1724
- scf->upstream.store = 1;
1725
1855
  return NGX_CONF_OK;
1726
1856
  }
1727
1857
 
@@ -1753,26 +1883,53 @@ ngx_http_scgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1753
1883
  {
1754
1884
  ngx_http_scgi_loc_conf_t *scf = conf;
1755
1885
 
1756
- ngx_str_t *value;
1886
+ ngx_str_t *value;
1887
+ ngx_http_complex_value_t cv;
1888
+ ngx_http_compile_complex_value_t ccv;
1757
1889
 
1758
1890
  value = cf->args->elts;
1759
1891
 
1760
- if (scf->upstream.cache != NGX_CONF_UNSET_PTR) {
1892
+ if (scf->upstream.cache != NGX_CONF_UNSET) {
1761
1893
  return "is duplicate";
1762
1894
  }
1763
1895
 
1764
1896
  if (ngx_strcmp(value[1].data, "off") == 0) {
1765
- scf->upstream.cache = NULL;
1897
+ scf->upstream.cache = 0;
1766
1898
  return NGX_CONF_OK;
1767
1899
  }
1768
1900
 
1769
- if (scf->upstream.store > 0 || scf->upstream.store_lengths) {
1901
+ if (scf->upstream.store > 0) {
1770
1902
  return "is incompatible with \"scgi_store\"";
1771
1903
  }
1772
1904
 
1773
- scf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0,
1774
- &ngx_http_scgi_module);
1775
- if (scf->upstream.cache == NULL) {
1905
+ scf->upstream.cache = 1;
1906
+
1907
+ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
1908
+
1909
+ ccv.cf = cf;
1910
+ ccv.value = &value[1];
1911
+ ccv.complex_value = &cv;
1912
+
1913
+ if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
1914
+ return NGX_CONF_ERROR;
1915
+ }
1916
+
1917
+ if (cv.lengths != NULL) {
1918
+
1919
+ scf->upstream.cache_value = ngx_palloc(cf->pool,
1920
+ sizeof(ngx_http_complex_value_t));
1921
+ if (scf->upstream.cache_value == NULL) {
1922
+ return NGX_CONF_ERROR;
1923
+ }
1924
+
1925
+ *scf->upstream.cache_value = cv;
1926
+
1927
+ return NGX_CONF_OK;
1928
+ }
1929
+
1930
+ scf->upstream.cache_zone = ngx_shared_memory_add(cf, &value[1], 0,
1931
+ &ngx_http_scgi_module);
1932
+ if (scf->upstream.cache_zone == NULL) {
1776
1933
  return NGX_CONF_ERROR;
1777
1934
  }
1778
1935