Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_scgi_module.c @ 4278:f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
The following problems were fixed:
1. Directive fastcgi_cache affected headers sent to backends in unrelated
servers / locations (see ticket #45).
2. If-Unmodified-Since, If-Match and If-Range headers were sent to backends
if fastcgi_cache was used.
3. Cache-related headers were sent to backends if there were no fastcgi_param
directives and fastcgi_cache was used at server level.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 14 Nov 2011 13:26:18 +0000 |
parents | e4b8255e44c3 |
children | 56cb2255735a |
comparison
equal
deleted
inserted
replaced
4277:e4b8255e44c3 | 4278:f57229cba7ad |
---|---|
1314 ngx_http_scgi_loc_conf_t *prev) | 1314 ngx_http_scgi_loc_conf_t *prev) |
1315 { | 1315 { |
1316 u_char *p; | 1316 u_char *p; |
1317 size_t size; | 1317 size_t size; |
1318 uintptr_t *code; | 1318 uintptr_t *code; |
1319 ngx_uint_t i; | 1319 ngx_uint_t i, nsrc; |
1320 ngx_array_t headers_names; | 1320 ngx_array_t headers_names; |
1321 #if (NGX_HTTP_CACHE) | |
1322 ngx_array_t params_merged; | |
1323 #endif | |
1321 ngx_keyval_t *src; | 1324 ngx_keyval_t *src; |
1322 ngx_hash_key_t *hk; | 1325 ngx_hash_key_t *hk; |
1323 ngx_hash_init_t hash; | 1326 ngx_hash_init_t hash; |
1324 ngx_http_script_compile_t sc; | 1327 ngx_http_script_compile_t sc; |
1325 ngx_http_script_copy_code_t *copy; | 1328 ngx_http_script_copy_code_t *copy; |
1326 | 1329 |
1327 if (conf->params_source == NULL) { | 1330 if (conf->params_source == NULL) { |
1328 conf->flushes = prev->flushes; | |
1329 conf->params_len = prev->params_len; | |
1330 conf->params = prev->params; | |
1331 conf->params_source = prev->params_source; | 1331 conf->params_source = prev->params_source; |
1332 conf->headers_hash = prev->headers_hash; | 1332 |
1333 | 1333 if (prev->headers_hash.buckets |
1334 #if (NGX_HTTP_CACHE) | 1334 #if (NGX_HTTP_CACHE) |
1335 | 1335 && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) |
1336 if (conf->params_source == NULL) { | 1336 #endif |
1337 | 1337 ) |
1338 if ((conf->upstream.cache == NULL) | 1338 { |
1339 == (prev->upstream.cache == NULL)) | 1339 conf->flushes = prev->flushes; |
1340 { | 1340 conf->params_len = prev->params_len; |
1341 return NGX_OK; | 1341 conf->params = prev->params; |
1342 } | 1342 conf->headers_hash = prev->headers_hash; |
1343 | 1343 conf->header_params = prev->header_params; |
1344 /* 6 is a number of ngx_http_scgi_cache_headers entries */ | 1344 |
1345 conf->params_source = ngx_array_create(cf->pool, 6, | |
1346 sizeof(ngx_keyval_t)); | |
1347 if (conf->params_source == NULL) { | |
1348 return NGX_ERROR; | |
1349 } | |
1350 } | |
1351 #else | |
1352 | |
1353 if (conf->params_source == NULL) { | |
1354 return NGX_OK; | 1345 return NGX_OK; |
1355 } | 1346 } |
1356 | 1347 } |
1348 | |
1349 if (conf->params_source == NULL | |
1350 #if (NGX_HTTP_CACHE) | |
1351 && (conf->upstream.cache == NULL) | |
1357 #endif | 1352 #endif |
1353 ) | |
1354 { | |
1355 conf->headers_hash.buckets = (void *) 1; | |
1356 return NGX_OK; | |
1358 } | 1357 } |
1359 | 1358 |
1360 conf->params_len = ngx_array_create(cf->pool, 64, 1); | 1359 conf->params_len = ngx_array_create(cf->pool, 64, 1); |
1361 if (conf->params_len == NULL) { | 1360 if (conf->params_len == NULL) { |
1362 return NGX_ERROR; | 1361 return NGX_ERROR; |
1371 != NGX_OK) | 1370 != NGX_OK) |
1372 { | 1371 { |
1373 return NGX_ERROR; | 1372 return NGX_ERROR; |
1374 } | 1373 } |
1375 | 1374 |
1376 src = conf->params_source->elts; | 1375 if (conf->params_source) { |
1376 src = conf->params_source->elts; | |
1377 nsrc = conf->params_source->nelts; | |
1378 | |
1379 } else { | |
1380 src = NULL; | |
1381 nsrc = 0; | |
1382 } | |
1377 | 1383 |
1378 #if (NGX_HTTP_CACHE) | 1384 #if (NGX_HTTP_CACHE) |
1379 | 1385 |
1380 if (conf->upstream.cache) { | 1386 if (conf->upstream.cache) { |
1381 ngx_keyval_t *h, *s; | 1387 ngx_keyval_t *h, *s; |
1382 | 1388 |
1383 for (h = ngx_http_scgi_cache_headers; h->key.len; h++) { | 1389 if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) |
1384 | 1390 != NGX_OK) |
1385 for (i = 0; i < conf->params_source->nelts; i++) { | 1391 { |
1392 return NGX_ERROR; | |
1393 } | |
1394 | |
1395 for (i = 0; i < nsrc; i++) { | |
1396 | |
1397 s = ngx_array_push(¶ms_merged); | |
1398 if (s == NULL) { | |
1399 return NGX_ERROR; | |
1400 } | |
1401 | |
1402 *s = src[i]; | |
1403 } | |
1404 | |
1405 h = ngx_http_scgi_cache_headers; | |
1406 | |
1407 while (h->key.len) { | |
1408 | |
1409 src = params_merged.elts; | |
1410 nsrc = params_merged.nelts; | |
1411 | |
1412 for (i = 0; i < nsrc; i++) { | |
1386 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { | 1413 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { |
1387 goto next; | 1414 goto next; |
1388 } | 1415 } |
1389 } | 1416 } |
1390 | 1417 |
1391 s = ngx_array_push(conf->params_source); | 1418 s = ngx_array_push(¶ms_merged); |
1392 if (s == NULL) { | 1419 if (s == NULL) { |
1393 return NGX_ERROR; | 1420 return NGX_ERROR; |
1394 } | 1421 } |
1395 | 1422 |
1396 *s = *h; | 1423 *s = *h; |
1397 | 1424 |
1398 src = conf->params_source->elts; | |
1399 | |
1400 next: | 1425 next: |
1401 | 1426 |
1402 h++; | 1427 h++; |
1403 } | 1428 } |
1429 | |
1430 src = params_merged.elts; | |
1431 nsrc = params_merged.nelts; | |
1404 } | 1432 } |
1405 | 1433 |
1406 #endif | 1434 #endif |
1407 | 1435 |
1408 for (i = 0; i < conf->params_source->nelts; i++) { | 1436 for (i = 0; i < nsrc; i++) { |
1409 | 1437 |
1410 if (src[i].key.len > sizeof("HTTP_") - 1 | 1438 if (src[i].key.len > sizeof("HTTP_") - 1 |
1411 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) | 1439 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) |
1412 { | 1440 { |
1413 hk = ngx_array_push(&headers_names); | 1441 hk = ngx_array_push(&headers_names); |