comparison src/http/modules/ngx_http_ssi_filter_module.c @ 160:73e8476f9142 NGINX_0_3_27

nginx 0.3.27 *) Change: the "variables_hash_max_size" and "variables_hash_bucket_size" directives. *) Feature: the $body_bytes_sent variable can be used not only in the "log_format" directive. *) Feature: the $ssl_protocol and $ssl_cipher variables. *) Feature: the cache line size detection for widespread CPUs at start time. *) Feature: now the "accept_mutex" directive is supported using fcntl(2) on platforms different from i386, amd64, sparc64, and ppc. *) Feature: the "lock_file" directive and the --with-lock-path=PATH autoconfiguration directive. *) Bugfix: if the HTTPS protocol was used in the "proxy_pass" directive then the requests with the body was not transferred.
author Igor Sysoev <http://sysoev.ru>
date Wed, 08 Feb 2006 00:00:00 +0300
parents 2d15b82126ed
children 87699398f955
comparison
equal deleted inserted replaced
159:25c27e983933 160:73e8476f9142
27 } ngx_http_ssi_loc_conf_t; 27 } ngx_http_ssi_loc_conf_t;
28 28
29 29
30 typedef struct { 30 typedef struct {
31 ngx_str_t name; 31 ngx_str_t name;
32 ngx_uint_t key;
32 ngx_str_t value; 33 ngx_str_t value;
33 } ngx_http_ssi_var_t; 34 } ngx_http_ssi_var_t;
34 35
35 36
36 typedef enum { 37 typedef enum {
60 static ngx_int_t ngx_http_ssi_output(ngx_http_request_t *r, 61 static ngx_int_t ngx_http_ssi_output(ngx_http_request_t *r,
61 ngx_http_ssi_ctx_t *ctx); 62 ngx_http_ssi_ctx_t *ctx);
62 static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, 63 static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r,
63 ngx_http_ssi_ctx_t *ctx); 64 ngx_http_ssi_ctx_t *ctx);
64 static ngx_str_t *ngx_http_ssi_get_variable(ngx_http_request_t *r, 65 static ngx_str_t *ngx_http_ssi_get_variable(ngx_http_request_t *r,
65 ngx_str_t *name); 66 ngx_str_t *name, ngx_uint_t key);
66 static ngx_int_t ngx_http_ssi_evaluate_string(ngx_http_request_t *r, 67 static ngx_int_t ngx_http_ssi_evaluate_string(ngx_http_request_t *r,
67 ngx_http_ssi_ctx_t *ctx, ngx_str_t *text, ngx_uint_t flags); 68 ngx_http_ssi_ctx_t *ctx, ngx_str_t *text, ngx_uint_t flags);
68 69
69 static ngx_int_t ngx_http_ssi_include(ngx_http_request_t *r, 70 static ngx_int_t ngx_http_ssi_include(ngx_http_request_t *r,
70 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); 71 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params);
1333 return NGX_AGAIN; 1334 return NGX_AGAIN;
1334 } 1335 }
1335 1336
1336 1337
1337 static ngx_str_t * 1338 static ngx_str_t *
1338 ngx_http_ssi_get_variable(ngx_http_request_t *r, ngx_str_t *name) 1339 ngx_http_ssi_get_variable(ngx_http_request_t *r, ngx_str_t *name,
1340 ngx_uint_t key)
1339 { 1341 {
1340 ngx_uint_t i; 1342 ngx_uint_t i;
1341 ngx_http_ssi_var_t *var; 1343 ngx_http_ssi_var_t *var;
1342 ngx_http_ssi_ctx_t *ctx; 1344 ngx_http_ssi_ctx_t *ctx;
1343 1345
1347 for (i = 0; i < ctx->variables.nelts; i++) { 1349 for (i = 0; i < ctx->variables.nelts; i++) {
1348 if (name->len != var[i].name.len) { 1350 if (name->len != var[i].name.len) {
1349 continue; 1351 continue;
1350 } 1352 }
1351 1353
1352 if (ngx_strncasecmp(name->data, var[i].name.data, name->len) == 0) { 1354 if (key != var[i].key) {
1355 continue;
1356 }
1357
1358 if (ngx_strncmp(name->data, var[i].name.data, name->len) == 0) {
1353 return &var[i].value; 1359 return &var[i].value;
1354 } 1360 }
1355 } 1361 }
1356 1362
1357 return NULL; 1363 return NULL;
1363 ngx_str_t *text, ngx_uint_t flags) 1369 ngx_str_t *text, ngx_uint_t flags)
1364 { 1370 {
1365 u_char ch, *p, **value, *data, *part_data; 1371 u_char ch, *p, **value, *data, *part_data;
1366 size_t *size, len, prefix, part_len; 1372 size_t *size, len, prefix, part_len;
1367 ngx_str_t var, *val; 1373 ngx_str_t var, *val;
1374 ngx_int_t key;
1368 ngx_uint_t i, j, n, bracket; 1375 ngx_uint_t i, j, n, bracket;
1369 ngx_array_t lengths, values; 1376 ngx_array_t lengths, values;
1370 ngx_http_variable_value_t *vv; 1377 ngx_http_variable_value_t *vv;
1371 1378
1372 n = ngx_http_script_variables_count(text); 1379 n = ngx_http_script_variables_count(text);
1467 1474
1468 if (var.len == 0) { 1475 if (var.len == 0) {
1469 goto invalid_variable; 1476 goto invalid_variable;
1470 } 1477 }
1471 1478
1479 key = 0;
1480
1472 for (j = 0; j < var.len; j++) { 1481 for (j = 0; j < var.len; j++) {
1473 var.data[j] = ngx_tolower(var.data[j]); 1482 var.data[j] = ngx_tolower(var.data[j]);
1474 } 1483 key = ngx_hash(key, var.data[j]);
1475 1484 }
1476 val = ngx_http_ssi_get_variable(r, &var); 1485
1486 val = ngx_http_ssi_get_variable(r, &var, key);
1477 1487
1478 if (val == NULL) { 1488 if (val == NULL) {
1479 vv = ngx_http_get_variable(r, &var); 1489 vv = ngx_http_get_variable(r, &var, key);
1480 1490
1481 if (vv == NULL) { 1491 if (vv == NULL) {
1482 return NGX_ERROR; 1492 return NGX_ERROR;
1483 } 1493 }
1484 1494
1634 1644
1635 static ngx_int_t 1645 static ngx_int_t
1636 ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, 1646 ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
1637 ngx_str_t **params) 1647 ngx_str_t **params)
1638 { 1648 {
1649 ngx_int_t key;
1639 ngx_uint_t i; 1650 ngx_uint_t i;
1640 ngx_buf_t *b; 1651 ngx_buf_t *b;
1641 ngx_str_t *var, *value, text; 1652 ngx_str_t *var, *value, text;
1642 ngx_chain_t *cl; 1653 ngx_chain_t *cl;
1643 ngx_http_variable_value_t *vv; 1654 ngx_http_variable_value_t *vv;
1644 1655
1645 var = params[NGX_HTTP_SSI_ECHO_VAR]; 1656 var = params[NGX_HTTP_SSI_ECHO_VAR];
1646 1657
1647 value = ngx_http_ssi_get_variable(r, var); 1658 key = 0;
1659
1660 for (i = 0; i < var->len; i++) {
1661 var->data[i] = ngx_tolower(var->data[i]);
1662 key = ngx_hash(key, var->data[i]);
1663 }
1664
1665 value = ngx_http_ssi_get_variable(r, var, key);
1648 1666
1649 if (value == NULL) { 1667 if (value == NULL) {
1650 for (i = 0; i < var->len; i++) { 1668 vv = ngx_http_get_variable(r, var, key);
1651 var->data[i] = ngx_tolower(var->data[i]);
1652 }
1653
1654 vv = ngx_http_get_variable(r, var);
1655 1669
1656 if (vv == NULL) { 1670 if (vv == NULL) {
1657 return NGX_HTTP_SSI_ERROR; 1671 return NGX_HTTP_SSI_ERROR;
1658 } 1672 }
1659 1673
1733 1747
1734 static ngx_int_t 1748 static ngx_int_t
1735 ngx_http_ssi_set(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, 1749 ngx_http_ssi_set(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
1736 ngx_str_t **params) 1750 ngx_str_t **params)
1737 { 1751 {
1752 ngx_int_t key;
1753 ngx_uint_t i;
1738 ngx_str_t *name, *value, *vv; 1754 ngx_str_t *name, *value, *vv;
1739 ngx_http_ssi_var_t *var; 1755 ngx_http_ssi_var_t *var;
1740 ngx_http_ssi_ctx_t *mctx; 1756 ngx_http_ssi_ctx_t *mctx;
1741 1757
1742 mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); 1758 mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module);
1754 1770
1755 if (ngx_http_ssi_evaluate_string(r, ctx, value, 0) != NGX_OK) { 1771 if (ngx_http_ssi_evaluate_string(r, ctx, value, 0) != NGX_OK) {
1756 return NGX_HTTP_SSI_ERROR; 1772 return NGX_HTTP_SSI_ERROR;
1757 } 1773 }
1758 1774
1759 vv = ngx_http_ssi_get_variable(r, name); 1775 key = 0;
1776
1777 for (i = 0; i < name->len; i++) {
1778 name->data[i] = ngx_tolower(name->data[i]);
1779 key = ngx_hash(key, name->data[i]);
1780 }
1781
1782 vv = ngx_http_ssi_get_variable(r, name, key);
1760 1783
1761 if (vv) { 1784 if (vv) {
1762 *vv = *value; 1785 *vv = *value;
1763 return NGX_OK; 1786 return NGX_OK;
1764 } 1787 }
1767 if (var == NULL) { 1790 if (var == NULL) {
1768 return NGX_HTTP_SSI_ERROR; 1791 return NGX_HTTP_SSI_ERROR;
1769 } 1792 }
1770 1793
1771 var->name = *name; 1794 var->name = *name;
1795 var->key = key;
1772 var->value = *value; 1796 var->value = *value;
1773 1797
1774 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1798 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1775 "set: \"%V\"=\"%V\"", name, value); 1799 "set: \"%V\"=\"%V\"", name, value);
1776 1800