diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2006-02-08 15:33:12 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2006-02-08 15:33:12 +0000 |
| commit | ffe714403d604b385c89daa7fe5a83860a672a54 (patch) | |
| tree | 24ce46a2354a79212f91fdbc3d6045ea340c3f12 /src/http/modules | |
| parent | 2446d5d6adf67d81883024ffb20ec21d146c0450 (diff) | |
| download | nginx-release-0.3.27.tar.gz nginx-release-0.3.27.tar.bz2 | |
nginx-0.3.27-RELEASE importrelease-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.
Diffstat (limited to 'src/http/modules')
| -rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 2 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_referer_module.c | 2 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_ssi_filter_module.c | 48 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_ssl_module.c | 70 |
4 files changed, 109 insertions, 13 deletions
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index 579da9465..e66b48b8b 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -741,6 +741,8 @@ ngx_http_proxy_create_request(ngx_http_request_t *r) body = body->next; } + b->flush = 1; + } else { u->request_bufs = cl; } diff --git a/src/http/modules/ngx_http_referer_module.c b/src/http/modules/ngx_http_referer_module.c index 17a3427ca..4eac263a9 100644 --- a/src/http/modules/ngx_http_referer_module.c +++ b/src/http/modules/ngx_http_referer_module.c @@ -271,6 +271,8 @@ ngx_http_referer_merge_conf(ngx_conf_t *cf, void *parent, void *child) conf->blocked_referer = 0; } + conf->keys = NULL; + return NGX_CONF_OK; } diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c index 4ec674971..1b528f7fb 100644 --- a/src/http/modules/ngx_http_ssi_filter_module.c +++ b/src/http/modules/ngx_http_ssi_filter_module.c @@ -29,6 +29,7 @@ typedef struct { typedef struct { ngx_str_t name; + ngx_uint_t key; ngx_str_t value; } ngx_http_ssi_var_t; @@ -62,7 +63,7 @@ static ngx_int_t ngx_http_ssi_output(ngx_http_request_t *r, static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx); static ngx_str_t *ngx_http_ssi_get_variable(ngx_http_request_t *r, - ngx_str_t *name); + ngx_str_t *name, ngx_uint_t key); static ngx_int_t ngx_http_ssi_evaluate_string(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, ngx_str_t *text, ngx_uint_t flags); @@ -1335,7 +1336,8 @@ ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx) static ngx_str_t * -ngx_http_ssi_get_variable(ngx_http_request_t *r, ngx_str_t *name) +ngx_http_ssi_get_variable(ngx_http_request_t *r, ngx_str_t *name, + ngx_uint_t key) { ngx_uint_t i; ngx_http_ssi_var_t *var; @@ -1349,7 +1351,11 @@ ngx_http_ssi_get_variable(ngx_http_request_t *r, ngx_str_t *name) continue; } - if (ngx_strncasecmp(name->data, var[i].name.data, name->len) == 0) { + if (key != var[i].key) { + continue; + } + + if (ngx_strncmp(name->data, var[i].name.data, name->len) == 0) { return &var[i].value; } } @@ -1365,6 +1371,7 @@ ngx_http_ssi_evaluate_string(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, u_char ch, *p, **value, *data, *part_data; size_t *size, len, prefix, part_len; ngx_str_t var, *val; + ngx_int_t key; ngx_uint_t i, j, n, bracket; ngx_array_t lengths, values; ngx_http_variable_value_t *vv; @@ -1469,14 +1476,17 @@ ngx_http_ssi_evaluate_string(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, goto invalid_variable; } + key = 0; + for (j = 0; j < var.len; j++) { var.data[j] = ngx_tolower(var.data[j]); + key = ngx_hash(key, var.data[j]); } - val = ngx_http_ssi_get_variable(r, &var); + val = ngx_http_ssi_get_variable(r, &var, key); if (val == NULL) { - vv = ngx_http_get_variable(r, &var); + vv = ngx_http_get_variable(r, &var, key); if (vv == NULL) { return NGX_ERROR; @@ -1636,6 +1646,7 @@ static ngx_int_t ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, ngx_str_t **params) { + ngx_int_t key; ngx_uint_t i; ngx_buf_t *b; ngx_str_t *var, *value, text; @@ -1644,14 +1655,17 @@ ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, var = params[NGX_HTTP_SSI_ECHO_VAR]; - value = ngx_http_ssi_get_variable(r, var); + key = 0; - if (value == NULL) { - for (i = 0; i < var->len; i++) { - var->data[i] = ngx_tolower(var->data[i]); - } + for (i = 0; i < var->len; i++) { + var->data[i] = ngx_tolower(var->data[i]); + key = ngx_hash(key, var->data[i]); + } - vv = ngx_http_get_variable(r, var); + value = ngx_http_ssi_get_variable(r, var, key); + + if (value == NULL) { + vv = ngx_http_get_variable(r, var, key); if (vv == NULL) { return NGX_HTTP_SSI_ERROR; @@ -1735,6 +1749,8 @@ static ngx_int_t ngx_http_ssi_set(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, ngx_str_t **params) { + ngx_int_t key; + ngx_uint_t i; ngx_str_t *name, *value, *vv; ngx_http_ssi_var_t *var; ngx_http_ssi_ctx_t *mctx; @@ -1756,7 +1772,14 @@ ngx_http_ssi_set(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, return NGX_HTTP_SSI_ERROR; } - vv = ngx_http_ssi_get_variable(r, name); + key = 0; + + for (i = 0; i < name->len; i++) { + name->data[i] = ngx_tolower(name->data[i]); + key = ngx_hash(key, name->data[i]); + } + + vv = ngx_http_ssi_get_variable(r, name, key); if (vv) { *vv = *value; @@ -1769,6 +1792,7 @@ ngx_http_ssi_set(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, } var->name = *name; + var->key = key; var->value = *value; ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c index 55f7b48a7..a70c7f2f5 100644 --- a/src/http/modules/ngx_http_ssl_module.c +++ b/src/http/modules/ngx_http_ssl_module.c @@ -9,11 +9,18 @@ #include <ngx_http.h> +typedef u_char *(*ngx_ssl_variable_handler_pt)(ngx_connection_t *); + + #define NGX_DEFLAUT_CERTIFICATE "cert.pem" #define NGX_DEFLAUT_CERTIFICATE_KEY "cert.pem" #define NGX_DEFLAUT_CIPHERS "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP" +static ngx_int_t ngx_http_ssl_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); + +static ngx_int_t ngx_http_ssl_add_variables(ngx_conf_t *cf); static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf); static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child); @@ -97,7 +104,7 @@ static ngx_command_t ngx_http_ssl_commands[] = { static ngx_http_module_t ngx_http_ssl_module_ctx = { - NULL, /* preconfiguration */ + ngx_http_ssl_add_variables, /* preconfiguration */ NULL, /* postconfiguration */ NULL, /* create main configuration */ @@ -127,9 +134,70 @@ ngx_module_t ngx_http_ssl_module = { }; +static ngx_http_variable_t ngx_http_ssl_vars[] = { + + { ngx_string("ssl_protocol"), ngx_http_ssl_variable, + (uintptr_t) ngx_ssl_get_protocol, NGX_HTTP_VAR_CHANGABLE, 0 }, + + { ngx_string("ssl_cipher"), ngx_http_ssl_variable, + (uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGABLE, 0 }, + + { ngx_null_string, NULL, 0, 0, 0 } +}; + + static u_char ngx_http_session_id_ctx[] = "HTTP"; +static ngx_int_t +ngx_http_ssl_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data; + + size_t len; + u_char *name; + + if (r->connection->ssl) { + + name = handler(r->connection); + + for (len = 0; name[len]; len++) { /* void */ } + + v->len = len; + v->valid = 1; + v->no_cachable = 0; + v->not_found = 0; + v->data = name; + + return NGX_OK; + } + + v->not_found = 1; + + return NGX_OK; +} + + +static ngx_int_t +ngx_http_ssl_add_variables(ngx_conf_t *cf) +{ + ngx_http_variable_t *var, *v; + + for (v = ngx_http_ssl_vars; v->name.len; v++) { + var = ngx_http_add_variable(cf, &v->name, v->flags); + if (var == NULL) { + return NGX_ERROR; + } + + var->handler = v->handler; + var->data = v->data; + } + + return NGX_OK; +} + + static void * ngx_http_ssl_create_srv_conf(ngx_conf_t *cf) { |
