comparison src/http/modules/ngx_http_uwsgi_module.c @ 4277:e4b8255e44c3

Separate functions to merge fastcgi/scgi/uwsgi params. No functional changes.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 14 Nov 2011 13:24:43 +0000
parents 9d59a8eda373
children f57229cba7ad
comparison
equal deleted inserted replaced
4276:a0f18c78db3b 4277:e4b8255e44c3
48 ngx_int_t rc); 48 ngx_int_t rc);
49 49
50 static void *ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf); 50 static void *ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf);
51 static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, 51 static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
52 void *child); 52 void *child);
53 static ngx_int_t ngx_http_uwsgi_merge_params(ngx_conf_t *cf,
54 ngx_http_uwsgi_loc_conf_t *conf, ngx_http_uwsgi_loc_conf_t *prev);
53 55
54 static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, 56 static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
55 void *conf); 57 void *conf);
56 static char *ngx_http_uwsgi_store(ngx_conf_t *cf, ngx_command_t *cmd, 58 static char *ngx_http_uwsgi_store(ngx_conf_t *cf, ngx_command_t *cmd,
57 void *conf); 59 void *conf);
1110 ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) 1112 ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1111 { 1113 {
1112 ngx_http_uwsgi_loc_conf_t *prev = parent; 1114 ngx_http_uwsgi_loc_conf_t *prev = parent;
1113 ngx_http_uwsgi_loc_conf_t *conf = child; 1115 ngx_http_uwsgi_loc_conf_t *conf = child;
1114 1116
1117 size_t size;
1118 ngx_hash_init_t hash;
1119 ngx_http_core_loc_conf_t *clcf;
1120
1121 if (conf->upstream.store != 0) {
1122 ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
1123
1124 if (conf->upstream.store_lengths == NULL) {
1125 conf->upstream.store_lengths = prev->upstream.store_lengths;
1126 conf->upstream.store_values = prev->upstream.store_values;
1127 }
1128 }
1129
1130 ngx_conf_merge_uint_value(conf->upstream.store_access,
1131 prev->upstream.store_access, 0600);
1132
1133 ngx_conf_merge_value(conf->upstream.buffering,
1134 prev->upstream.buffering, 1);
1135
1136 ngx_conf_merge_value(conf->upstream.ignore_client_abort,
1137 prev->upstream.ignore_client_abort, 0);
1138
1139 ngx_conf_merge_msec_value(conf->upstream.connect_timeout,
1140 prev->upstream.connect_timeout, 60000);
1141
1142 ngx_conf_merge_msec_value(conf->upstream.send_timeout,
1143 prev->upstream.send_timeout, 60000);
1144
1145 ngx_conf_merge_msec_value(conf->upstream.read_timeout,
1146 prev->upstream.read_timeout, 60000);
1147
1148 ngx_conf_merge_size_value(conf->upstream.send_lowat,
1149 prev->upstream.send_lowat, 0);
1150
1151 ngx_conf_merge_size_value(conf->upstream.buffer_size,
1152 prev->upstream.buffer_size,
1153 (size_t) ngx_pagesize);
1154
1155
1156 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,
1157 8, ngx_pagesize);
1158
1159 if (conf->upstream.bufs.num < 2) {
1160 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1161 "there must be at least 2 \"uwsgi_buffers\"");
1162 return NGX_CONF_ERROR;
1163 }
1164
1165
1166 size = conf->upstream.buffer_size;
1167 if (size < conf->upstream.bufs.size) {
1168 size = conf->upstream.bufs.size;
1169 }
1170
1171
1172 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf,
1173 prev->upstream.busy_buffers_size_conf,
1174 NGX_CONF_UNSET_SIZE);
1175
1176 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {
1177 conf->upstream.busy_buffers_size = 2 * size;
1178 } else {
1179 conf->upstream.busy_buffers_size =
1180 conf->upstream.busy_buffers_size_conf;
1181 }
1182
1183 if (conf->upstream.busy_buffers_size < size) {
1184 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1185 "\"uwsgi_busy_buffers_size\" must be equal or bigger "
1186 "than maximum of the value of \"uwsgi_buffer_size\" and "
1187 "one of the \"uwsgi_buffers\"");
1188
1189 return NGX_CONF_ERROR;
1190 }
1191
1192 if (conf->upstream.busy_buffers_size
1193 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size)
1194 {
1195 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1196 "\"uwsgi_busy_buffers_size\" must be less than "
1197 "the size of all \"uwsgi_buffers\" minus one buffer");
1198
1199 return NGX_CONF_ERROR;
1200 }
1201
1202
1203 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf,
1204 prev->upstream.temp_file_write_size_conf,
1205 NGX_CONF_UNSET_SIZE);
1206
1207 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {
1208 conf->upstream.temp_file_write_size = 2 * size;
1209 } else {
1210 conf->upstream.temp_file_write_size =
1211 conf->upstream.temp_file_write_size_conf;
1212 }
1213
1214 if (conf->upstream.temp_file_write_size < size) {
1215 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1216 "\"uwsgi_temp_file_write_size\" must be equal or bigger than "
1217 "maximum of the value of \"uwsgi_buffer_size\" and "
1218 "one of the \"uwsgi_buffers\"");
1219
1220 return NGX_CONF_ERROR;
1221 }
1222
1223
1224 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf,
1225 prev->upstream.max_temp_file_size_conf,
1226 NGX_CONF_UNSET_SIZE);
1227
1228 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {
1229 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;
1230 } else {
1231 conf->upstream.max_temp_file_size =
1232 conf->upstream.max_temp_file_size_conf;
1233 }
1234
1235 if (conf->upstream.max_temp_file_size != 0
1236 && conf->upstream.max_temp_file_size < size) {
1237 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1238 "\"uwsgi_max_temp_file_size\" must be equal to zero to disable "
1239 "the temporary files usage or must be equal or bigger than "
1240 "maximum of the value of \"uwsgi_buffer_size\" and "
1241 "one of the \"uwsgi_buffers\"");
1242
1243 return NGX_CONF_ERROR;
1244 }
1245
1246
1247 ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers,
1248 prev->upstream.ignore_headers,
1249 NGX_CONF_BITMASK_SET);
1250
1251
1252 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream,
1253 prev->upstream.next_upstream,
1254 (NGX_CONF_BITMASK_SET
1255 |NGX_HTTP_UPSTREAM_FT_ERROR
1256 |NGX_HTTP_UPSTREAM_FT_TIMEOUT));
1257
1258 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
1259 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
1260 |NGX_HTTP_UPSTREAM_FT_OFF;
1261 }
1262
1263 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path,
1264 prev->upstream.temp_path,
1265 &ngx_http_uwsgi_temp_path)
1266 != NGX_OK)
1267 {
1268 return NGX_CONF_ERROR;
1269 }
1270
1271 #if (NGX_HTTP_CACHE)
1272
1273 ngx_conf_merge_ptr_value(conf->upstream.cache,
1274 prev->upstream.cache, NULL);
1275
1276 if (conf->upstream.cache && conf->upstream.cache->data == NULL) {
1277 ngx_shm_zone_t *shm_zone;
1278
1279 shm_zone = conf->upstream.cache;
1280
1281 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1282 "\"uwsgi_cache\" zone \"%V\" is unknown",
1283 &shm_zone->shm.name);
1284
1285 return NGX_CONF_ERROR;
1286 }
1287
1288 ngx_conf_merge_uint_value(conf->upstream.cache_min_uses,
1289 prev->upstream.cache_min_uses, 1);
1290
1291 ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale,
1292 prev->upstream.cache_use_stale,
1293 (NGX_CONF_BITMASK_SET
1294 |NGX_HTTP_UPSTREAM_FT_OFF));
1295
1296 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) {
1297 conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET
1298 |NGX_HTTP_UPSTREAM_FT_OFF;
1299 }
1300
1301 if (conf->upstream.cache_methods == 0) {
1302 conf->upstream.cache_methods = prev->upstream.cache_methods;
1303 }
1304
1305 conf->upstream.cache_methods |= NGX_HTTP_GET|NGX_HTTP_HEAD;
1306
1307 ngx_conf_merge_ptr_value(conf->upstream.cache_bypass,
1308 prev->upstream.cache_bypass, NULL);
1309
1310 ngx_conf_merge_ptr_value(conf->upstream.no_cache,
1311 prev->upstream.no_cache, NULL);
1312
1313 ngx_conf_merge_ptr_value(conf->upstream.cache_valid,
1314 prev->upstream.cache_valid, NULL);
1315
1316 if (conf->cache_key.value.data == NULL) {
1317 conf->cache_key = prev->cache_key;
1318 }
1319
1320 #endif
1321
1322 ngx_conf_merge_value(conf->upstream.pass_request_headers,
1323 prev->upstream.pass_request_headers, 1);
1324 ngx_conf_merge_value(conf->upstream.pass_request_body,
1325 prev->upstream.pass_request_body, 1);
1326
1327 ngx_conf_merge_value(conf->upstream.intercept_errors,
1328 prev->upstream.intercept_errors, 0);
1329
1330 ngx_conf_merge_str_value(conf->uwsgi_string, prev->uwsgi_string, "");
1331
1332 hash.max_size = 512;
1333 hash.bucket_size = ngx_align(64, ngx_cacheline_size);
1334 hash.name = "uwsgi_hide_headers_hash";
1335
1336 if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
1337 &prev->upstream, ngx_http_uwsgi_hide_headers, &hash)
1338 != NGX_OK)
1339 {
1340 return NGX_CONF_ERROR;
1341 }
1342
1343 if (conf->upstream.upstream == NULL) {
1344 conf->upstream.upstream = prev->upstream.upstream;
1345 }
1346
1347 if (conf->uwsgi_lengths == NULL) {
1348 conf->uwsgi_lengths = prev->uwsgi_lengths;
1349 conf->uwsgi_values = prev->uwsgi_values;
1350 }
1351
1352 if (conf->upstream.upstream || conf->uwsgi_lengths) {
1353 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1354 if (clcf->handler == NULL && clcf->lmt_excpt) {
1355 clcf->handler = ngx_http_uwsgi_handler;
1356 }
1357 }
1358
1359 ngx_conf_merge_uint_value(conf->modifier1, prev->modifier1, 0);
1360 ngx_conf_merge_uint_value(conf->modifier2, prev->modifier2, 0);
1361
1362 if (ngx_http_uwsgi_merge_params(cf, conf, prev) != NGX_OK) {
1363 return NGX_CONF_ERROR;
1364 }
1365
1366 return NGX_CONF_OK;
1367 }
1368
1369
1370 static ngx_int_t
1371 ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1372 ngx_http_uwsgi_loc_conf_t *prev)
1373 {
1115 u_char *p; 1374 u_char *p;
1116 size_t size; 1375 size_t size;
1117 uintptr_t *code; 1376 uintptr_t *code;
1118 ngx_uint_t i; 1377 ngx_uint_t i;
1119 ngx_array_t headers_names; 1378 ngx_array_t headers_names;
1120 ngx_keyval_t *src; 1379 ngx_keyval_t *src;
1121 ngx_hash_key_t *hk; 1380 ngx_hash_key_t *hk;
1122 ngx_hash_init_t hash; 1381 ngx_hash_init_t hash;
1123 ngx_http_core_loc_conf_t *clcf;
1124 ngx_http_script_compile_t sc; 1382 ngx_http_script_compile_t sc;
1125 ngx_http_script_copy_code_t *copy; 1383 ngx_http_script_copy_code_t *copy;
1126
1127 if (conf->upstream.store != 0) {
1128 ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
1129
1130 if (conf->upstream.store_lengths == NULL) {
1131 conf->upstream.store_lengths = prev->upstream.store_lengths;
1132 conf->upstream.store_values = prev->upstream.store_values;
1133 }
1134 }
1135
1136 ngx_conf_merge_uint_value(conf->upstream.store_access,
1137 prev->upstream.store_access, 0600);
1138
1139 ngx_conf_merge_value(conf->upstream.buffering,
1140 prev->upstream.buffering, 1);
1141
1142 ngx_conf_merge_value(conf->upstream.ignore_client_abort,
1143 prev->upstream.ignore_client_abort, 0);
1144
1145 ngx_conf_merge_msec_value(conf->upstream.connect_timeout,
1146 prev->upstream.connect_timeout, 60000);
1147
1148 ngx_conf_merge_msec_value(conf->upstream.send_timeout,
1149 prev->upstream.send_timeout, 60000);
1150
1151 ngx_conf_merge_msec_value(conf->upstream.read_timeout,
1152 prev->upstream.read_timeout, 60000);
1153
1154 ngx_conf_merge_size_value(conf->upstream.send_lowat,
1155 prev->upstream.send_lowat, 0);
1156
1157 ngx_conf_merge_size_value(conf->upstream.buffer_size,
1158 prev->upstream.buffer_size,
1159 (size_t) ngx_pagesize);
1160
1161
1162 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,
1163 8, ngx_pagesize);
1164
1165 if (conf->upstream.bufs.num < 2) {
1166 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1167 "there must be at least 2 \"uwsgi_buffers\"");
1168 return NGX_CONF_ERROR;
1169 }
1170
1171
1172 size = conf->upstream.buffer_size;
1173 if (size < conf->upstream.bufs.size) {
1174 size = conf->upstream.bufs.size;
1175 }
1176
1177
1178 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf,
1179 prev->upstream.busy_buffers_size_conf,
1180 NGX_CONF_UNSET_SIZE);
1181
1182 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {
1183 conf->upstream.busy_buffers_size = 2 * size;
1184 } else {
1185 conf->upstream.busy_buffers_size =
1186 conf->upstream.busy_buffers_size_conf;
1187 }
1188
1189 if (conf->upstream.busy_buffers_size < size) {
1190 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1191 "\"uwsgi_busy_buffers_size\" must be equal or bigger "
1192 "than maximum of the value of \"uwsgi_buffer_size\" and "
1193 "one of the \"uwsgi_buffers\"");
1194
1195 return NGX_CONF_ERROR;
1196 }
1197
1198 if (conf->upstream.busy_buffers_size
1199 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size)
1200 {
1201 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1202 "\"uwsgi_busy_buffers_size\" must be less than "
1203 "the size of all \"uwsgi_buffers\" minus one buffer");
1204
1205 return NGX_CONF_ERROR;
1206 }
1207
1208
1209 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf,
1210 prev->upstream.temp_file_write_size_conf,
1211 NGX_CONF_UNSET_SIZE);
1212
1213 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {
1214 conf->upstream.temp_file_write_size = 2 * size;
1215 } else {
1216 conf->upstream.temp_file_write_size =
1217 conf->upstream.temp_file_write_size_conf;
1218 }
1219
1220 if (conf->upstream.temp_file_write_size < size) {
1221 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1222 "\"uwsgi_temp_file_write_size\" must be equal or bigger than "
1223 "maximum of the value of \"uwsgi_buffer_size\" and "
1224 "one of the \"uwsgi_buffers\"");
1225
1226 return NGX_CONF_ERROR;
1227 }
1228
1229
1230 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf,
1231 prev->upstream.max_temp_file_size_conf,
1232 NGX_CONF_UNSET_SIZE);
1233
1234 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {
1235 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;
1236 } else {
1237 conf->upstream.max_temp_file_size =
1238 conf->upstream.max_temp_file_size_conf;
1239 }
1240
1241 if (conf->upstream.max_temp_file_size != 0
1242 && conf->upstream.max_temp_file_size < size) {
1243 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1244 "\"uwsgi_max_temp_file_size\" must be equal to zero to disable "
1245 "the temporary files usage or must be equal or bigger than "
1246 "maximum of the value of \"uwsgi_buffer_size\" and "
1247 "one of the \"uwsgi_buffers\"");
1248
1249 return NGX_CONF_ERROR;
1250 }
1251
1252
1253 ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers,
1254 prev->upstream.ignore_headers,
1255 NGX_CONF_BITMASK_SET);
1256
1257
1258 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream,
1259 prev->upstream.next_upstream,
1260 (NGX_CONF_BITMASK_SET
1261 |NGX_HTTP_UPSTREAM_FT_ERROR
1262 |NGX_HTTP_UPSTREAM_FT_TIMEOUT));
1263
1264 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
1265 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
1266 |NGX_HTTP_UPSTREAM_FT_OFF;
1267 }
1268
1269 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path,
1270 prev->upstream.temp_path,
1271 &ngx_http_uwsgi_temp_path)
1272 != NGX_OK)
1273 {
1274 return NGX_CONF_ERROR;
1275 }
1276
1277 #if (NGX_HTTP_CACHE)
1278
1279 ngx_conf_merge_ptr_value(conf->upstream.cache,
1280 prev->upstream.cache, NULL);
1281
1282 if (conf->upstream.cache && conf->upstream.cache->data == NULL) {
1283 ngx_shm_zone_t *shm_zone;
1284
1285 shm_zone = conf->upstream.cache;
1286
1287 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1288 "\"uwsgi_cache\" zone \"%V\" is unknown",
1289 &shm_zone->shm.name);
1290
1291 return NGX_CONF_ERROR;
1292 }
1293
1294 ngx_conf_merge_uint_value(conf->upstream.cache_min_uses,
1295 prev->upstream.cache_min_uses, 1);
1296
1297 ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale,
1298 prev->upstream.cache_use_stale,
1299 (NGX_CONF_BITMASK_SET
1300 |NGX_HTTP_UPSTREAM_FT_OFF));
1301
1302 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) {
1303 conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET
1304 |NGX_HTTP_UPSTREAM_FT_OFF;
1305 }
1306
1307 if (conf->upstream.cache_methods == 0) {
1308 conf->upstream.cache_methods = prev->upstream.cache_methods;
1309 }
1310
1311 conf->upstream.cache_methods |= NGX_HTTP_GET|NGX_HTTP_HEAD;
1312
1313 ngx_conf_merge_ptr_value(conf->upstream.cache_bypass,
1314 prev->upstream.cache_bypass, NULL);
1315
1316 ngx_conf_merge_ptr_value(conf->upstream.no_cache,
1317 prev->upstream.no_cache, NULL);
1318
1319 ngx_conf_merge_ptr_value(conf->upstream.cache_valid,
1320 prev->upstream.cache_valid, NULL);
1321
1322 if (conf->cache_key.value.data == NULL) {
1323 conf->cache_key = prev->cache_key;
1324 }
1325
1326 #endif
1327
1328 ngx_conf_merge_value(conf->upstream.pass_request_headers,
1329 prev->upstream.pass_request_headers, 1);
1330 ngx_conf_merge_value(conf->upstream.pass_request_body,
1331 prev->upstream.pass_request_body, 1);
1332
1333 ngx_conf_merge_value(conf->upstream.intercept_errors,
1334 prev->upstream.intercept_errors, 0);
1335
1336 ngx_conf_merge_str_value(conf->uwsgi_string, prev->uwsgi_string, "");
1337
1338 hash.max_size = 512;
1339 hash.bucket_size = ngx_align(64, ngx_cacheline_size);
1340 hash.name = "uwsgi_hide_headers_hash";
1341
1342 if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
1343 &prev->upstream, ngx_http_uwsgi_hide_headers, &hash)
1344 != NGX_OK)
1345 {
1346 return NGX_CONF_ERROR;
1347 }
1348
1349 if (conf->upstream.upstream == NULL) {
1350 conf->upstream.upstream = prev->upstream.upstream;
1351 }
1352
1353 if (conf->uwsgi_lengths == NULL) {
1354 conf->uwsgi_lengths = prev->uwsgi_lengths;
1355 conf->uwsgi_values = prev->uwsgi_values;
1356 }
1357
1358 if (conf->upstream.upstream || conf->uwsgi_lengths) {
1359 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1360 if (clcf->handler == NULL && clcf->lmt_excpt) {
1361 clcf->handler = ngx_http_uwsgi_handler;
1362 }
1363 }
1364
1365 ngx_conf_merge_uint_value(conf->modifier1, prev->modifier1, 0);
1366 ngx_conf_merge_uint_value(conf->modifier2, prev->modifier2, 0);
1367 1384
1368 if (conf->params_source == NULL) { 1385 if (conf->params_source == NULL) {
1369 conf->flushes = prev->flushes; 1386 conf->flushes = prev->flushes;
1370 conf->params_len = prev->params_len; 1387 conf->params_len = prev->params_len;
1371 conf->params = prev->params; 1388 conf->params = prev->params;
1377 if (conf->params_source == NULL) { 1394 if (conf->params_source == NULL) {
1378 1395
1379 if ((conf->upstream.cache == NULL) 1396 if ((conf->upstream.cache == NULL)
1380 == (prev->upstream.cache == NULL)) 1397 == (prev->upstream.cache == NULL))
1381 { 1398 {
1382 return NGX_CONF_OK; 1399 return NGX_OK;
1383 } 1400 }
1384 1401
1385 /* 6 is a number of ngx_http_uwsgi_cache_headers entries */ 1402 /* 6 is a number of ngx_http_uwsgi_cache_headers entries */
1386 conf->params_source = ngx_array_create(cf->pool, 6, 1403 conf->params_source = ngx_array_create(cf->pool, 6,
1387 sizeof(ngx_keyval_t)); 1404 sizeof(ngx_keyval_t));
1388 if (conf->params_source == NULL) { 1405 if (conf->params_source == NULL) {
1389 return NGX_CONF_ERROR; 1406 return NGX_ERROR;
1390 } 1407 }
1391 } 1408 }
1392 #else 1409 #else
1393 1410
1394 if (conf->params_source == NULL) { 1411 if (conf->params_source == NULL) {
1395 return NGX_CONF_OK; 1412 return NGX_OK;
1396 } 1413 }
1397 1414
1398 #endif 1415 #endif
1399 } 1416 }
1400 1417
1401 conf->params_len = ngx_array_create(cf->pool, 64, 1); 1418 conf->params_len = ngx_array_create(cf->pool, 64, 1);
1402 if (conf->params_len == NULL) { 1419 if (conf->params_len == NULL) {
1403 return NGX_CONF_ERROR; 1420 return NGX_ERROR;
1404 } 1421 }
1405 1422
1406 conf->params = ngx_array_create(cf->pool, 512, 1); 1423 conf->params = ngx_array_create(cf->pool, 512, 1);
1407 if (conf->params == NULL) { 1424 if (conf->params == NULL) {
1408 return NGX_CONF_ERROR; 1425 return NGX_ERROR;
1409 } 1426 }
1410 1427
1411 if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t)) 1428 if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
1412 != NGX_OK) 1429 != NGX_OK)
1413 { 1430 {
1414 return NGX_CONF_ERROR; 1431 return NGX_ERROR;
1415 } 1432 }
1416 1433
1417 src = conf->params_source->elts; 1434 src = conf->params_source->elts;
1418 1435
1419 #if (NGX_HTTP_CACHE) 1436 #if (NGX_HTTP_CACHE)
1429 } 1446 }
1430 } 1447 }
1431 1448
1432 s = ngx_array_push(conf->params_source); 1449 s = ngx_array_push(conf->params_source);
1433 if (s == NULL) { 1450 if (s == NULL) {
1434 return NGX_CONF_ERROR; 1451 return NGX_ERROR;
1435 } 1452 }
1436 1453
1437 *s = *h; 1454 *s = *h;
1438 1455
1439 src = conf->params_source->elts; 1456 src = conf->params_source->elts;
1451 if (src[i].key.len > sizeof("HTTP_") - 1 1468 if (src[i].key.len > sizeof("HTTP_") - 1
1452 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) 1469 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0)
1453 { 1470 {
1454 hk = ngx_array_push(&headers_names); 1471 hk = ngx_array_push(&headers_names);
1455 if (hk == NULL) { 1472 if (hk == NULL) {
1456 return NGX_CONF_ERROR; 1473 return NGX_ERROR;
1457 } 1474 }
1458 1475
1459 hk->key.len = src[i].key.len - 5; 1476 hk->key.len = src[i].key.len - 5;
1460 hk->key.data = src[i].key.data + 5; 1477 hk->key.data = src[i].key.data + 5;
1461 hk->key_hash = ngx_hash_key_lc(hk->key.data, hk->key.len); 1478 hk->key_hash = ngx_hash_key_lc(hk->key.data, hk->key.len);
1467 } 1484 }
1468 1485
1469 copy = ngx_array_push_n(conf->params_len, 1486 copy = ngx_array_push_n(conf->params_len,
1470 sizeof(ngx_http_script_copy_code_t)); 1487 sizeof(ngx_http_script_copy_code_t));
1471 if (copy == NULL) { 1488 if (copy == NULL) {
1472 return NGX_CONF_ERROR; 1489 return NGX_ERROR;
1473 } 1490 }
1474 1491
1475 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; 1492 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
1476 copy->len = src[i].key.len; 1493 copy->len = src[i].key.len;
1477 1494
1480 + src[i].key.len + sizeof(uintptr_t) - 1) 1497 + src[i].key.len + sizeof(uintptr_t) - 1)
1481 & ~(sizeof(uintptr_t) - 1); 1498 & ~(sizeof(uintptr_t) - 1);
1482 1499
1483 copy = ngx_array_push_n(conf->params, size); 1500 copy = ngx_array_push_n(conf->params, size);
1484 if (copy == NULL) { 1501 if (copy == NULL) {
1485 return NGX_CONF_ERROR; 1502 return NGX_ERROR;
1486 } 1503 }
1487 1504
1488 copy->code = ngx_http_script_copy_code; 1505 copy->code = ngx_http_script_copy_code;
1489 copy->len = src[i].key.len; 1506 copy->len = src[i].key.len;
1490 1507
1499 sc.flushes = &conf->flushes; 1516 sc.flushes = &conf->flushes;
1500 sc.lengths = &conf->params_len; 1517 sc.lengths = &conf->params_len;
1501 sc.values = &conf->params; 1518 sc.values = &conf->params;
1502 1519
1503 if (ngx_http_script_compile(&sc) != NGX_OK) { 1520 if (ngx_http_script_compile(&sc) != NGX_OK) {
1504 return NGX_CONF_ERROR; 1521 return NGX_ERROR;
1505 } 1522 }
1506 1523
1507 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); 1524 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
1508 if (code == NULL) { 1525 if (code == NULL) {
1509 return NGX_CONF_ERROR; 1526 return NGX_ERROR;
1510 } 1527 }
1511 1528
1512 *code = (uintptr_t) NULL; 1529 *code = (uintptr_t) NULL;
1513 1530
1514 1531
1515 code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); 1532 code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
1516 if (code == NULL) { 1533 if (code == NULL) {
1517 return NGX_CONF_ERROR; 1534 return NGX_ERROR;
1518 } 1535 }
1519 1536
1520 *code = (uintptr_t) NULL; 1537 *code = (uintptr_t) NULL;
1521 } 1538 }
1522 1539
1523 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); 1540 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
1524 if (code == NULL) { 1541 if (code == NULL) {
1525 return NGX_CONF_ERROR; 1542 return NGX_ERROR;
1526 } 1543 }
1527 1544
1528 *code = (uintptr_t) NULL; 1545 *code = (uintptr_t) NULL;
1529 1546
1530 conf->header_params = headers_names.nelts; 1547 conf->header_params = headers_names.nelts;
1535 hash.bucket_size = 64; 1552 hash.bucket_size = 64;
1536 hash.name = "uwsgi_params_hash"; 1553 hash.name = "uwsgi_params_hash";
1537 hash.pool = cf->pool; 1554 hash.pool = cf->pool;
1538 hash.temp_pool = NULL; 1555 hash.temp_pool = NULL;
1539 1556
1540 if (ngx_hash_init(&hash, headers_names.elts, headers_names.nelts) != NGX_OK) 1557 return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts);
1541 {
1542 return NGX_CONF_ERROR;
1543 }
1544
1545 return NGX_CONF_OK;
1546 } 1558 }
1547 1559
1548 1560
1549 static char * 1561 static char *
1550 ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 1562 ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)