No functional changes.
#include <ngx_http.h>
+typedef struct {
+ ngx_array_t *flushes;
+ ngx_array_t *lengths;
+ ngx_array_t *values;
+ ngx_uint_t number;
+ ngx_hash_t hash;
+} ngx_http_fastcgi_params_t;
+
+
typedef struct {
ngx_http_upstream_conf_t upstream;
ngx_str_t index;
- ngx_array_t *flushes;
- ngx_array_t *params_len;
- ngx_array_t *params;
+ ngx_http_fastcgi_params_t params;
+
ngx_array_t *params_source;
ngx_array_t *catch_stderr;
ngx_array_t *fastcgi_lengths;
ngx_array_t *fastcgi_values;
- ngx_hash_t headers_hash;
- ngx_uint_t header_params;
-
ngx_flag_t keep_conn;
#if (NGX_HTTP_CACHE)
static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child);
static ngx_int_t ngx_http_fastcgi_init_params(ngx_conf_t *cf,
- ngx_http_fastcgi_loc_conf_t *conf);
+ ngx_http_fastcgi_loc_conf_t *conf, ngx_http_fastcgi_params_t *params);
static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
ngx_http_script_code_pt code;
ngx_http_script_engine_t e, le;
ngx_http_fastcgi_header_t *h;
+ ngx_http_fastcgi_params_t *params;
ngx_http_fastcgi_loc_conf_t *flcf;
ngx_http_script_len_code_pt lcode;
flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
- if (flcf->params_len) {
+ params = &flcf->params;
+
+ if (params->lengths) {
ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
- ngx_http_script_flush_no_cacheable_variables(r, flcf->flushes);
+ ngx_http_script_flush_no_cacheable_variables(r, params->flushes);
le.flushed = 1;
- le.ip = flcf->params_len->elts;
+ le.ip = params->lengths->elts;
le.request = r;
while (*(uintptr_t *) le.ip) {
allocated = 0;
lowcase_key = NULL;
- if (flcf->header_params) {
+ if (params->number) {
n = 0;
part = &r->headers_in.headers.part;
i = 0;
}
- if (flcf->header_params) {
+ if (params->number) {
if (allocated < header[i].key.len) {
allocated = header[i].key.len + 16;
lowcase_key = ngx_pnalloc(r->pool, allocated);
lowcase_key[n] = ch;
}
- if (ngx_hash_find(&flcf->headers_hash, hash, lowcase_key, n)) {
+ if (ngx_hash_find(¶ms->hash, hash, lowcase_key, n)) {
ignored[header_params++] = &header[i];
continue;
}
+ sizeof(ngx_http_fastcgi_header_t);
- if (flcf->params_len) {
+ if (params->lengths) {
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
- e.ip = flcf->params->elts;
+ e.ip = params->values->elts;
e.pos = b->last;
e.request = r;
e.flushed = 1;
- le.ip = flcf->params_len->elts;
+ le.ip = params->lengths->elts;
while (*(uintptr_t *) le.ip) {
if ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL))
#endif
{
- conf->flushes = prev->flushes;
- conf->params_len = prev->params_len;
conf->params = prev->params;
- conf->headers_hash = prev->headers_hash;
- conf->header_params = prev->header_params;
}
}
- if (ngx_http_fastcgi_init_params(cf, conf) != NGX_OK) {
+ if (ngx_http_fastcgi_init_params(cf, conf, &conf->params) != NGX_OK) {
return NGX_CONF_ERROR;
}
static ngx_int_t
-ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
+ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf,
+ ngx_http_fastcgi_params_t *params)
{
u_char *p;
size_t size;
ngx_http_script_compile_t sc;
ngx_http_script_copy_code_t *copy;
- if (conf->headers_hash.buckets) {
+ if (params->hash.buckets) {
return NGX_OK;
}
#endif
)
{
- conf->headers_hash.buckets = (void *) 1;
+ params->hash.buckets = (void *) 1;
return NGX_OK;
}
- conf->params_len = ngx_array_create(cf->pool, 64, 1);
- if (conf->params_len == NULL) {
+ params->lengths = ngx_array_create(cf->pool, 64, 1);
+ if (params->lengths == NULL) {
return NGX_ERROR;
}
- conf->params = ngx_array_create(cf->pool, 512, 1);
- if (conf->params == NULL) {
+ params->values = ngx_array_create(cf->pool, 512, 1);
+ if (params->values == NULL) {
return NGX_ERROR;
}
}
}
- copy = ngx_array_push_n(conf->params_len,
+ copy = ngx_array_push_n(params->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
- copy = ngx_array_push_n(conf->params_len,
+ copy = ngx_array_push_n(params->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
+ src[i].key.len + sizeof(uintptr_t) - 1)
& ~(sizeof(uintptr_t) - 1);
- copy = ngx_array_push_n(conf->params, size);
+ copy = ngx_array_push_n(params->values, size);
if (copy == NULL) {
return NGX_ERROR;
}
sc.cf = cf;
sc.source = &src[i].value;
- sc.flushes = &conf->flushes;
- sc.lengths = &conf->params_len;
- sc.values = &conf->params;
+ sc.flushes = ¶ms->flushes;
+ sc.lengths = ¶ms->lengths;
+ sc.values = ¶ms->values;
if (ngx_http_script_compile(&sc) != NGX_OK) {
return NGX_ERROR;
}
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
- code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->values, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
}
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
- conf->header_params = headers_names.nelts;
+ params->number = headers_names.nelts;
- hash.hash = &conf->headers_hash;
+ hash.hash = ¶ms->hash;
hash.key = ngx_hash_key_lc;
hash.max_size = 512;
hash.bucket_size = 64;
} ngx_http_proxy_vars_t;
+typedef struct {
+ ngx_array_t *flushes;
+ ngx_array_t *lengths;
+ ngx_array_t *values;
+ ngx_hash_t hash;
+} ngx_http_proxy_headers_t;
+
+
typedef struct {
ngx_http_upstream_conf_t upstream;
- ngx_array_t *flushes;
+ ngx_array_t *body_flushes;
ngx_array_t *body_set_len;
ngx_array_t *body_set;
- ngx_array_t *headers_set_len;
- ngx_array_t *headers_set;
- ngx_hash_t headers_set_hash;
+ ngx_http_proxy_headers_t headers;
ngx_array_t *headers_source;
ngx_array_t *proxy_lengths;
static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child);
static ngx_int_t ngx_http_proxy_init_headers(ngx_conf_t *cf,
- ngx_http_proxy_loc_conf_t *conf);
+ ngx_http_proxy_loc_conf_t *conf, ngx_http_proxy_headers_t *headers);
static char *ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
ngx_http_upstream_t *u;
ngx_http_proxy_ctx_t *ctx;
ngx_http_script_code_pt code;
+ ngx_http_proxy_headers_t *headers;
ngx_http_script_engine_t e, le;
ngx_http_proxy_loc_conf_t *plcf;
ngx_http_script_len_code_pt lcode;
plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module);
+ headers = &plcf->headers;
+
if (u->method.len) {
/* HEAD was changed to GET to cache response */
method = u->method;
ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
- ngx_http_script_flush_no_cacheable_variables(r, plcf->flushes);
+ ngx_http_script_flush_no_cacheable_variables(r, plcf->body_flushes);
+ ngx_http_script_flush_no_cacheable_variables(r, headers->flushes);
if (plcf->body_set_len) {
le.ip = plcf->body_set_len->elts;
ctx->internal_body_length = r->headers_in.content_length_n;
}
- le.ip = plcf->headers_set_len->elts;
+ le.ip = headers->lengths->elts;
le.request = r;
le.flushed = 1;
i = 0;
}
- if (ngx_hash_find(&plcf->headers_set_hash, header[i].hash,
+ if (ngx_hash_find(&headers->hash, header[i].hash,
header[i].lowcase_key, header[i].key.len))
{
continue;
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
- e.ip = plcf->headers_set->elts;
+ e.ip = headers->values->elts;
e.pos = b->last;
e.request = r;
e.flushed = 1;
- le.ip = plcf->headers_set_len->elts;
+ le.ip = headers->lengths->elts;
while (*(uintptr_t *) le.ip) {
lcode = *(ngx_http_script_len_code_pt *) le.ip;
i = 0;
}
- if (ngx_hash_find(&plcf->headers_set_hash, header[i].hash,
+ if (ngx_hash_find(&headers->hash, header[i].hash,
header[i].lowcase_key, header[i].key.len))
{
continue;
*
* conf->method = { 0, NULL };
* conf->headers_source = NULL;
- * conf->headers_set_len = NULL;
- * conf->headers_set = NULL;
- * conf->headers_set_hash = NULL;
+ * conf->headers.lengths = NULL;
+ * conf->headers.values = NULL;
+ * conf->headers.hash = { NULL, 0 };
* conf->body_set_len = NULL;
* conf->body_set = NULL;
* conf->body_source = { 0, NULL };
}
if (conf->body_source.data == NULL) {
+ conf->body_flushes = prev->body_flushes;
conf->body_source = prev->body_source;
conf->body_set_len = prev->body_set_len;
conf->body_set = prev->body_set;
sc.cf = cf;
sc.source = &conf->body_source;
- sc.flushes = &conf->flushes;
+ sc.flushes = &conf->body_flushes;
sc.lengths = &conf->body_set_len;
sc.values = &conf->body_set;
sc.complete_lengths = 1;
}
if (conf->headers_source == NULL) {
- conf->flushes = prev->flushes;
- conf->headers_set_len = prev->headers_set_len;
- conf->headers_set = prev->headers_set;
- conf->headers_set_hash = prev->headers_set_hash;
+ conf->headers = prev->headers;
conf->headers_source = prev->headers_source;
}
#if (NGX_HTTP_CACHE)
if ((conf->upstream.cache == NULL) != (prev->upstream.cache == NULL)) {
- conf->headers_set_hash.buckets = NULL;
+ conf->headers.hash.buckets = NULL;
}
#endif
- if (ngx_http_proxy_init_headers(cf, conf) != NGX_OK) {
+ if (ngx_http_proxy_init_headers(cf, conf, &conf->headers) != NGX_OK) {
return NGX_CONF_ERROR;
}
static ngx_int_t
-ngx_http_proxy_init_headers(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *conf)
+ngx_http_proxy_init_headers(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *conf,
+ ngx_http_proxy_headers_t *headers)
{
u_char *p;
size_t size;
ngx_http_script_compile_t sc;
ngx_http_script_copy_code_t *copy;
- if (conf->headers_set_hash.buckets) {
+ if (headers->hash.buckets) {
return NGX_OK;
}
}
}
- conf->headers_set_len = ngx_array_create(cf->pool, 64, 1);
- if (conf->headers_set_len == NULL) {
+ headers->lengths = ngx_array_create(cf->pool, 64, 1);
+ if (headers->lengths == NULL) {
return NGX_ERROR;
}
- conf->headers_set = ngx_array_create(cf->pool, 512, 1);
- if (conf->headers_set == NULL) {
+ headers->values = ngx_array_create(cf->pool, 512, 1);
+ if (headers->values == NULL) {
return NGX_ERROR;
}
}
if (ngx_http_script_variables_count(&src[i].value) == 0) {
- copy = ngx_array_push_n(conf->headers_set_len,
+ copy = ngx_array_push_n(headers->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
+ sizeof(uintptr_t) - 1)
& ~(sizeof(uintptr_t) - 1);
- copy = ngx_array_push_n(conf->headers_set, size);
+ copy = ngx_array_push_n(headers->values, size);
if (copy == NULL) {
return NGX_ERROR;
}
*p++ = CR; *p = LF;
} else {
- copy = ngx_array_push_n(conf->headers_set_len,
+ copy = ngx_array_push_n(headers->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
+ src[i].key.len + sizeof(": ") - 1 + sizeof(uintptr_t) - 1)
& ~(sizeof(uintptr_t) - 1);
- copy = ngx_array_push_n(conf->headers_set, size);
+ copy = ngx_array_push_n(headers->values, size);
if (copy == NULL) {
return NGX_ERROR;
}
sc.cf = cf;
sc.source = &src[i].value;
- sc.flushes = &conf->flushes;
- sc.lengths = &conf->headers_set_len;
- sc.values = &conf->headers_set;
+ sc.flushes = &headers->flushes;
+ sc.lengths = &headers->lengths;
+ sc.values = &headers->values;
if (ngx_http_script_compile(&sc) != NGX_OK) {
return NGX_ERROR;
}
- copy = ngx_array_push_n(conf->headers_set_len,
+ copy = ngx_array_push_n(headers->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
+ sizeof(CRLF) - 1 + sizeof(uintptr_t) - 1)
& ~(sizeof(uintptr_t) - 1);
- copy = ngx_array_push_n(conf->headers_set, size);
+ copy = ngx_array_push_n(headers->values, size);
if (copy == NULL) {
return NGX_ERROR;
}
*p++ = CR; *p = LF;
}
- code = ngx_array_push_n(conf->headers_set_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(headers->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
- code = ngx_array_push_n(conf->headers_set, sizeof(uintptr_t));
+ code = ngx_array_push_n(headers->values, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
}
- code = ngx_array_push_n(conf->headers_set_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(headers->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
- hash.hash = &conf->headers_set_hash;
+ hash.hash = &headers->hash;
hash.key = ngx_hash_key_lc;
hash.max_size = conf->headers_hash_max_size;
hash.bucket_size = conf->headers_hash_bucket_size;
#include <ngx_http.h>
+typedef struct {
+ ngx_array_t *flushes;
+ ngx_array_t *lengths;
+ ngx_array_t *values;
+ ngx_uint_t number;
+ ngx_hash_t hash;
+} ngx_http_scgi_params_t;
+
+
typedef struct {
ngx_http_upstream_conf_t upstream;
- ngx_array_t *flushes;
- ngx_array_t *params_len;
- ngx_array_t *params;
+ ngx_http_scgi_params_t params;
ngx_array_t *params_source;
- ngx_hash_t headers_hash;
- ngx_uint_t header_params;
-
ngx_array_t *scgi_lengths;
ngx_array_t *scgi_values;
static char *ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
void *child);
static ngx_int_t ngx_http_scgi_init_params(ngx_conf_t *cf,
- ngx_http_scgi_loc_conf_t *conf);
+ ngx_http_scgi_loc_conf_t *conf, ngx_http_scgi_params_t *params);
static char *ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd,
ngx_chain_t *cl, *body;
ngx_list_part_t *part;
ngx_table_elt_t *header, **ignored;
+ ngx_http_scgi_params_t *params;
ngx_http_script_code_pt code;
ngx_http_script_engine_t e, le;
ngx_http_scgi_loc_conf_t *scf;
scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module);
- if (scf->params_len) {
+ params = &scf->params;
+
+ if (params->lengths) {
ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
- ngx_http_script_flush_no_cacheable_variables(r, scf->flushes);
+ ngx_http_script_flush_no_cacheable_variables(r, params->flushes);
le.flushed = 1;
- le.ip = scf->params_len->elts;
+ le.ip = params->lengths->elts;
le.request = r;
while (*(uintptr_t *) le.ip) {
allocated = 0;
lowcase_key = NULL;
- if (scf->header_params) {
+ if (params->number) {
n = 0;
part = &r->headers_in.headers.part;
i = 0;
}
- if (scf->header_params) {
+ if (params->number) {
if (allocated < header[i].key.len) {
allocated = header[i].key.len + 16;
lowcase_key = ngx_pnalloc(r->pool, allocated);
lowcase_key[n] = ch;
}
- if (ngx_hash_find(&scf->headers_hash, hash, lowcase_key, n)) {
+ if (ngx_hash_find(¶ms->hash, hash, lowcase_key, n)) {
ignored[header_params++] = &header[i];
continue;
}
b->last = ngx_sprintf(b->last, "%ui:CONTENT_LENGTH%Z%V%Z",
len, &content_length);
- if (scf->params_len) {
+ if (params->lengths) {
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
- e.ip = scf->params->elts;
+ e.ip = params->values->elts;
e.pos = b->last;
e.request = r;
e.flushed = 1;
- le.ip = scf->params_len->elts;
+ le.ip = params->lengths->elts;
while (*(uintptr_t *) le.ip) {
if ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL))
#endif
{
- conf->flushes = prev->flushes;
- conf->params_len = prev->params_len;
conf->params = prev->params;
- conf->headers_hash = prev->headers_hash;
- conf->header_params = prev->header_params;
}
}
- if (ngx_http_scgi_init_params(cf, conf) != NGX_OK) {
+ if (ngx_http_scgi_init_params(cf, conf, &conf->params) != NGX_OK) {
return NGX_CONF_ERROR;
}
static ngx_int_t
-ngx_http_scgi_init_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf)
+ngx_http_scgi_init_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf,
+ ngx_http_scgi_params_t *params)
{
u_char *p;
size_t size;
ngx_http_script_compile_t sc;
ngx_http_script_copy_code_t *copy;
- if (conf->headers_hash.buckets) {
+ if (params->hash.buckets) {
return NGX_OK;
}
#endif
)
{
- conf->headers_hash.buckets = (void *) 1;
+ params->hash.buckets = (void *) 1;
return NGX_OK;
}
- conf->params_len = ngx_array_create(cf->pool, 64, 1);
- if (conf->params_len == NULL) {
+ params->lengths = ngx_array_create(cf->pool, 64, 1);
+ if (params->lengths == NULL) {
return NGX_ERROR;
}
- conf->params = ngx_array_create(cf->pool, 512, 1);
- if (conf->params == NULL) {
+ params->values = ngx_array_create(cf->pool, 512, 1);
+ if (params->values == NULL) {
return NGX_ERROR;
}
}
}
- copy = ngx_array_push_n(conf->params_len,
+ copy = ngx_array_push_n(params->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
copy->len = src[i].key.len + 1;
- copy = ngx_array_push_n(conf->params_len,
+ copy = ngx_array_push_n(params->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
+ src[i].key.len + 1 + sizeof(uintptr_t) - 1)
& ~(sizeof(uintptr_t) - 1);
- copy = ngx_array_push_n(conf->params, size);
+ copy = ngx_array_push_n(params->values, size);
if (copy == NULL) {
return NGX_ERROR;
}
sc.cf = cf;
sc.source = &src[i].value;
- sc.flushes = &conf->flushes;
- sc.lengths = &conf->params_len;
- sc.values = &conf->params;
+ sc.flushes = ¶ms->flushes;
+ sc.lengths = ¶ms->lengths;
+ sc.values = ¶ms->values;
if (ngx_http_script_compile(&sc) != NGX_OK) {
return NGX_ERROR;
}
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
- code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->values, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
}
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
- conf->header_params = headers_names.nelts;
+ params->number = headers_names.nelts;
- hash.hash = &conf->headers_hash;
+ hash.hash = ¶ms->hash;
hash.key = ngx_hash_key_lc;
hash.max_size = 512;
hash.bucket_size = 64;
#include <ngx_http.h>
+typedef struct {
+ ngx_array_t *flushes;
+ ngx_array_t *lengths;
+ ngx_array_t *values;
+ ngx_uint_t number;
+ ngx_hash_t hash;
+} ngx_http_uwsgi_params_t;
+
+
typedef struct {
ngx_http_upstream_conf_t upstream;
- ngx_array_t *flushes;
- ngx_array_t *params_len;
- ngx_array_t *params;
+ ngx_http_uwsgi_params_t params;
ngx_array_t *params_source;
- ngx_hash_t headers_hash;
- ngx_uint_t header_params;
-
ngx_array_t *uwsgi_lengths;
ngx_array_t *uwsgi_values;
static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
void *child);
static ngx_int_t ngx_http_uwsgi_init_params(ngx_conf_t *cf,
- ngx_http_uwsgi_loc_conf_t *conf);
+ ngx_http_uwsgi_loc_conf_t *conf, ngx_http_uwsgi_params_t *params);
static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
ngx_chain_t *cl, *body;
ngx_list_part_t *part;
ngx_table_elt_t *header, **ignored;
+ ngx_http_uwsgi_params_t *params;
ngx_http_script_code_pt code;
ngx_http_script_engine_t e, le;
ngx_http_uwsgi_loc_conf_t *uwcf;
uwcf = ngx_http_get_module_loc_conf(r, ngx_http_uwsgi_module);
- if (uwcf->params_len) {
+ params = &uwcf->params;
+
+ if (params->lengths) {
ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
- ngx_http_script_flush_no_cacheable_variables(r, uwcf->flushes);
+ ngx_http_script_flush_no_cacheable_variables(r, params->flushes);
le.flushed = 1;
- le.ip = uwcf->params_len->elts;
+ le.ip = params->lengths->elts;
le.request = r;
while (*(uintptr_t *) le.ip) {
allocated = 0;
lowcase_key = NULL;
- if (uwcf->header_params) {
+ if (params->number) {
n = 0;
part = &r->headers_in.headers.part;
i = 0;
}
- if (uwcf->header_params) {
+ if (params->number) {
if (allocated < header[i].key.len) {
allocated = header[i].key.len + 16;
lowcase_key = ngx_pnalloc(r->pool, allocated);
lowcase_key[n] = ch;
}
- if (ngx_hash_find(&uwcf->headers_hash, hash, lowcase_key, n)) {
+ if (ngx_hash_find(¶ms->hash, hash, lowcase_key, n)) {
ignored[header_params++] = &header[i];
continue;
}
*b->last++ = (u_char) ((len >> 8) & 0xff);
*b->last++ = (u_char) uwcf->modifier2;
- if (uwcf->params_len) {
+ if (params->lengths) {
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
- e.ip = uwcf->params->elts;
+ e.ip = params->values->elts;
e.pos = b->last;
e.request = r;
e.flushed = 1;
- le.ip = uwcf->params_len->elts;
+ le.ip = params->lengths->elts;
while (*(uintptr_t *) le.ip) {
if ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL))
#endif
{
- conf->flushes = prev->flushes;
- conf->params_len = prev->params_len;
conf->params = prev->params;
- conf->headers_hash = prev->headers_hash;
- conf->header_params = prev->header_params;
}
}
- if (ngx_http_uwsgi_init_params(cf, conf) != NGX_OK) {
+ if (ngx_http_uwsgi_init_params(cf, conf, &conf->params) != NGX_OK) {
return NGX_CONF_ERROR;
}
static ngx_int_t
-ngx_http_uwsgi_init_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf)
+ngx_http_uwsgi_init_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
+ ngx_http_uwsgi_params_t *params)
{
u_char *p;
size_t size;
ngx_http_script_compile_t sc;
ngx_http_script_copy_code_t *copy;
- if (conf->headers_hash.buckets) {
+ if (params->hash.buckets) {
return NGX_OK;
}
#endif
)
{
- conf->headers_hash.buckets = (void *) 1;
+ params->hash.buckets = (void *) 1;
return NGX_OK;
}
- conf->params_len = ngx_array_create(cf->pool, 64, 1);
- if (conf->params_len == NULL) {
+ params->lengths = ngx_array_create(cf->pool, 64, 1);
+ if (params->lengths == NULL) {
return NGX_ERROR;
}
- conf->params = ngx_array_create(cf->pool, 512, 1);
- if (conf->params == NULL) {
+ params->values = ngx_array_create(cf->pool, 512, 1);
+ if (params->values == NULL) {
return NGX_ERROR;
}
}
}
- copy = ngx_array_push_n(conf->params_len,
+ copy = ngx_array_push_n(params->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
- copy = ngx_array_push_n(conf->params_len,
+ copy = ngx_array_push_n(params->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
+ src[i].key.len + sizeof(uintptr_t) - 1)
& ~(sizeof(uintptr_t) - 1);
- copy = ngx_array_push_n(conf->params, size);
+ copy = ngx_array_push_n(params->values, size);
if (copy == NULL) {
return NGX_ERROR;
}
sc.cf = cf;
sc.source = &src[i].value;
- sc.flushes = &conf->flushes;
- sc.lengths = &conf->params_len;
- sc.values = &conf->params;
+ sc.flushes = ¶ms->flushes;
+ sc.lengths = ¶ms->lengths;
+ sc.values = ¶ms->values;
if (ngx_http_script_compile(&sc) != NGX_OK) {
return NGX_ERROR;
}
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
- code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->values, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
}
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
- conf->header_params = headers_names.nelts;
+ params->number = headers_names.nelts;
- hash.hash = &conf->headers_hash;
+ hash.hash = ¶ms->hash;
hash.key = ngx_hash_key_lc;
hash.max_size = 512;
hash.bucket_size = 64;