Mercurial > hg > nginx
comparison src/http/modules/ngx_http_uwsgi_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 | 5ee5ddec17b1 |
comparison
equal
deleted
inserted
replaced
4277:e4b8255e44c3 | 4278:f57229cba7ad |
---|---|
1372 ngx_http_uwsgi_loc_conf_t *prev) | 1372 ngx_http_uwsgi_loc_conf_t *prev) |
1373 { | 1373 { |
1374 u_char *p; | 1374 u_char *p; |
1375 size_t size; | 1375 size_t size; |
1376 uintptr_t *code; | 1376 uintptr_t *code; |
1377 ngx_uint_t i; | 1377 ngx_uint_t i, nsrc; |
1378 ngx_array_t headers_names; | 1378 ngx_array_t headers_names; |
1379 #if (NGX_HTTP_CACHE) | |
1380 ngx_array_t params_merged; | |
1381 #endif | |
1379 ngx_keyval_t *src; | 1382 ngx_keyval_t *src; |
1380 ngx_hash_key_t *hk; | 1383 ngx_hash_key_t *hk; |
1381 ngx_hash_init_t hash; | 1384 ngx_hash_init_t hash; |
1382 ngx_http_script_compile_t sc; | 1385 ngx_http_script_compile_t sc; |
1383 ngx_http_script_copy_code_t *copy; | 1386 ngx_http_script_copy_code_t *copy; |
1384 | 1387 |
1385 if (conf->params_source == NULL) { | 1388 if (conf->params_source == NULL) { |
1386 conf->flushes = prev->flushes; | |
1387 conf->params_len = prev->params_len; | |
1388 conf->params = prev->params; | |
1389 conf->params_source = prev->params_source; | 1389 conf->params_source = prev->params_source; |
1390 conf->headers_hash = prev->headers_hash; | 1390 |
1391 | 1391 if (prev->headers_hash.buckets |
1392 #if (NGX_HTTP_CACHE) | 1392 #if (NGX_HTTP_CACHE) |
1393 | 1393 && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) |
1394 if (conf->params_source == NULL) { | 1394 #endif |
1395 | 1395 ) |
1396 if ((conf->upstream.cache == NULL) | 1396 { |
1397 == (prev->upstream.cache == NULL)) | 1397 conf->flushes = prev->flushes; |
1398 { | 1398 conf->params_len = prev->params_len; |
1399 return NGX_OK; | 1399 conf->params = prev->params; |
1400 } | 1400 conf->headers_hash = prev->headers_hash; |
1401 | 1401 conf->header_params = prev->header_params; |
1402 /* 6 is a number of ngx_http_uwsgi_cache_headers entries */ | 1402 |
1403 conf->params_source = ngx_array_create(cf->pool, 6, | |
1404 sizeof(ngx_keyval_t)); | |
1405 if (conf->params_source == NULL) { | |
1406 return NGX_ERROR; | |
1407 } | |
1408 } | |
1409 #else | |
1410 | |
1411 if (conf->params_source == NULL) { | |
1412 return NGX_OK; | 1403 return NGX_OK; |
1413 } | 1404 } |
1414 | 1405 } |
1406 | |
1407 if (conf->params_source == NULL | |
1408 #if (NGX_HTTP_CACHE) | |
1409 && (conf->upstream.cache == NULL) | |
1415 #endif | 1410 #endif |
1411 ) | |
1412 { | |
1413 conf->headers_hash.buckets = (void *) 1; | |
1414 return NGX_OK; | |
1416 } | 1415 } |
1417 | 1416 |
1418 conf->params_len = ngx_array_create(cf->pool, 64, 1); | 1417 conf->params_len = ngx_array_create(cf->pool, 64, 1); |
1419 if (conf->params_len == NULL) { | 1418 if (conf->params_len == NULL) { |
1420 return NGX_ERROR; | 1419 return NGX_ERROR; |
1429 != NGX_OK) | 1428 != NGX_OK) |
1430 { | 1429 { |
1431 return NGX_ERROR; | 1430 return NGX_ERROR; |
1432 } | 1431 } |
1433 | 1432 |
1434 src = conf->params_source->elts; | 1433 if (conf->params_source) { |
1434 src = conf->params_source->elts; | |
1435 nsrc = conf->params_source->nelts; | |
1436 | |
1437 } else { | |
1438 src = NULL; | |
1439 nsrc = 0; | |
1440 } | |
1435 | 1441 |
1436 #if (NGX_HTTP_CACHE) | 1442 #if (NGX_HTTP_CACHE) |
1437 | 1443 |
1438 if (conf->upstream.cache) { | 1444 if (conf->upstream.cache) { |
1439 ngx_keyval_t *h, *s; | 1445 ngx_keyval_t *h, *s; |
1440 | 1446 |
1441 for (h = ngx_http_uwsgi_cache_headers; h->key.len; h++) { | 1447 if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) |
1442 | 1448 != NGX_OK) |
1443 for (i = 0; i < conf->params_source->nelts; i++) { | 1449 { |
1450 return NGX_ERROR; | |
1451 } | |
1452 | |
1453 for (i = 0; i < nsrc; i++) { | |
1454 | |
1455 s = ngx_array_push(¶ms_merged); | |
1456 if (s == NULL) { | |
1457 return NGX_ERROR; | |
1458 } | |
1459 | |
1460 *s = src[i]; | |
1461 } | |
1462 | |
1463 h = ngx_http_uwsgi_cache_headers; | |
1464 | |
1465 while (h->key.len) { | |
1466 | |
1467 src = params_merged.elts; | |
1468 nsrc = params_merged.nelts; | |
1469 | |
1470 for (i = 0; i < nsrc; i++) { | |
1444 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { | 1471 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { |
1445 goto next; | 1472 goto next; |
1446 } | 1473 } |
1447 } | 1474 } |
1448 | 1475 |
1449 s = ngx_array_push(conf->params_source); | 1476 s = ngx_array_push(¶ms_merged); |
1450 if (s == NULL) { | 1477 if (s == NULL) { |
1451 return NGX_ERROR; | 1478 return NGX_ERROR; |
1452 } | 1479 } |
1453 | 1480 |
1454 *s = *h; | 1481 *s = *h; |
1455 | 1482 |
1456 src = conf->params_source->elts; | |
1457 | |
1458 next: | 1483 next: |
1459 | 1484 |
1460 h++; | 1485 h++; |
1461 } | 1486 } |
1487 | |
1488 src = params_merged.elts; | |
1489 nsrc = params_merged.nelts; | |
1462 } | 1490 } |
1463 | 1491 |
1464 #endif | 1492 #endif |
1465 | 1493 |
1466 for (i = 0; i < conf->params_source->nelts; i++) { | 1494 for (i = 0; i < nsrc; i++) { |
1467 | 1495 |
1468 if (src[i].key.len > sizeof("HTTP_") - 1 | 1496 if (src[i].key.len > sizeof("HTTP_") - 1 |
1469 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) | 1497 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) |
1470 { | 1498 { |
1471 hk = ngx_array_push(&headers_names); | 1499 hk = ngx_array_push(&headers_names); |