Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_proxy_module.c @ 1381:d59617e7e6a1 stable-0.5
r1292, r1296 merge:
proxy_store and fastcgi_store, proxy_store_access and fastcgi_store_access
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 11 Aug 2007 10:11:33 +0000 |
parents | 99914ee62b48 |
children | bf5b86d5f00e |
comparison
equal
deleted
inserted
replaced
1360:e06ffbeccf71 | 1381:d59617e7e6a1 |
---|---|
103 | 103 |
104 static char *ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, | 104 static char *ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, |
105 void *conf); | 105 void *conf); |
106 static char *ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, | 106 static char *ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, |
107 void *conf); | 107 void *conf); |
108 static char *ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd, | |
109 void *conf); | |
108 | 110 |
109 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data); | 111 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data); |
110 | 112 |
111 static char *ngx_http_proxy_upstream_max_fails_unsupported(ngx_conf_t *cf, | 113 static char *ngx_http_proxy_upstream_max_fails_unsupported(ngx_conf_t *cf, |
112 ngx_command_t *cmd, void *conf); | 114 ngx_command_t *cmd, void *conf); |
150 { ngx_string("proxy_redirect"), | 152 { ngx_string("proxy_redirect"), |
151 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12, | 153 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12, |
152 ngx_http_proxy_redirect, | 154 ngx_http_proxy_redirect, |
153 NGX_HTTP_LOC_CONF_OFFSET, | 155 NGX_HTTP_LOC_CONF_OFFSET, |
154 0, | 156 0, |
157 NULL }, | |
158 | |
159 { ngx_string("proxy_store"), | |
160 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
161 ngx_http_proxy_store, | |
162 NGX_HTTP_LOC_CONF_OFFSET, | |
163 0, | |
164 NULL }, | |
165 | |
166 { ngx_string("proxy_store_access"), | |
167 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, | |
168 ngx_conf_set_access_slot, | |
169 NGX_HTTP_LOC_CONF_OFFSET, | |
170 offsetof(ngx_http_proxy_loc_conf_t, upstream.store_access), | |
155 NULL }, | 171 NULL }, |
156 | 172 |
157 { ngx_string("proxy_buffering"), | 173 { ngx_string("proxy_buffering"), |
158 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | 174 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
159 ngx_conf_set_flag_slot, | 175 ngx_conf_set_flag_slot, |
1488 * conf->upstream.hide_headers = NULL; | 1504 * conf->upstream.hide_headers = NULL; |
1489 * conf->upstream.pass_headers = NULL; | 1505 * conf->upstream.pass_headers = NULL; |
1490 * conf->upstream.schema = { 0, NULL }; | 1506 * conf->upstream.schema = { 0, NULL }; |
1491 * conf->upstream.uri = { 0, NULL }; | 1507 * conf->upstream.uri = { 0, NULL }; |
1492 * conf->upstream.location = NULL; | 1508 * conf->upstream.location = NULL; |
1509 * conf->upstream.store_lengths = NULL; | |
1510 * conf->upstream.store_values = NULL; | |
1493 * | 1511 * |
1494 * conf->method = NULL; | 1512 * conf->method = NULL; |
1495 * conf->headers_source = NULL; | 1513 * conf->headers_source = NULL; |
1496 * conf->headers_set_len = NULL; | 1514 * conf->headers_set_len = NULL; |
1497 * conf->headers_set = NULL; | 1515 * conf->headers_set = NULL; |
1500 * conf->body_set = NULL; | 1518 * conf->body_set = NULL; |
1501 * conf->body_source = { 0, NULL }; | 1519 * conf->body_source = { 0, NULL }; |
1502 * conf->rewrite_locations = NULL; | 1520 * conf->rewrite_locations = NULL; |
1503 */ | 1521 */ |
1504 | 1522 |
1523 conf->upstream.store = NGX_CONF_UNSET; | |
1524 conf->upstream.store_access = NGX_CONF_UNSET_UINT; | |
1505 conf->upstream.buffering = NGX_CONF_UNSET; | 1525 conf->upstream.buffering = NGX_CONF_UNSET; |
1506 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; | 1526 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; |
1507 | 1527 |
1508 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; | 1528 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
1509 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | 1529 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; |
1551 ngx_hash_init_t hash; | 1571 ngx_hash_init_t hash; |
1552 ngx_http_proxy_redirect_t *pr; | 1572 ngx_http_proxy_redirect_t *pr; |
1553 ngx_http_script_compile_t sc; | 1573 ngx_http_script_compile_t sc; |
1554 ngx_http_script_copy_code_t *copy; | 1574 ngx_http_script_copy_code_t *copy; |
1555 | 1575 |
1576 if (conf->upstream.store != 0) { | |
1577 ngx_conf_merge_value(conf->upstream.store, | |
1578 prev->upstream.store, 0); | |
1579 | |
1580 if (conf->upstream.store_lengths == NULL) { | |
1581 conf->upstream.store_lengths = prev->upstream.store_lengths; | |
1582 conf->upstream.store_values = prev->upstream.store_values; | |
1583 } | |
1584 } | |
1585 | |
1586 ngx_conf_merge_uint_value(conf->upstream.store_access, | |
1587 prev->upstream.store_access, 0600); | |
1588 | |
1556 ngx_conf_merge_value(conf->upstream.buffering, | 1589 ngx_conf_merge_value(conf->upstream.buffering, |
1557 prev->upstream.buffering, 1); | 1590 prev->upstream.buffering, 1); |
1558 | 1591 |
1559 ngx_conf_merge_value(conf->upstream.ignore_client_abort, | 1592 ngx_conf_merge_value(conf->upstream.ignore_client_abort, |
1560 prev->upstream.ignore_client_abort, 0); | 1593 prev->upstream.ignore_client_abort, 0); |
2358 return NGX_CONF_OK; | 2391 return NGX_CONF_OK; |
2359 } | 2392 } |
2360 | 2393 |
2361 | 2394 |
2362 static char * | 2395 static char * |
2396 ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2397 { | |
2398 ngx_http_proxy_loc_conf_t *plcf = conf; | |
2399 | |
2400 ngx_str_t *value; | |
2401 ngx_http_script_compile_t sc; | |
2402 | |
2403 if (plcf->upstream.store != NGX_CONF_UNSET || plcf->upstream.store_lengths) | |
2404 { | |
2405 return "is duplicate"; | |
2406 } | |
2407 | |
2408 value = cf->args->elts; | |
2409 | |
2410 if (ngx_strcmp(value[1].data, "on") == 0) { | |
2411 plcf->upstream.store = 1; | |
2412 return NGX_CONF_OK; | |
2413 } | |
2414 | |
2415 if (ngx_strcmp(value[1].data, "off") == 0) { | |
2416 plcf->upstream.store = 0; | |
2417 return NGX_CONF_OK; | |
2418 } | |
2419 | |
2420 /* include the terminating '\0' into script */ | |
2421 value[1].len++; | |
2422 | |
2423 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
2424 | |
2425 sc.cf = cf; | |
2426 sc.source = &value[1]; | |
2427 sc.lengths = &plcf->upstream.store_lengths; | |
2428 sc.values = &plcf->upstream.store_values; | |
2429 sc.variables = ngx_http_script_variables_count(&value[1]);; | |
2430 sc.complete_lengths = 1; | |
2431 sc.complete_values = 1; | |
2432 | |
2433 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
2434 return NGX_CONF_ERROR; | |
2435 } | |
2436 | |
2437 return NGX_CONF_OK; | |
2438 } | |
2439 | |
2440 | |
2441 static char * | |
2363 ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) | 2442 ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) |
2364 { | 2443 { |
2365 #if (NGX_FREEBSD) | 2444 #if (NGX_FREEBSD) |
2366 ssize_t *np = data; | 2445 ssize_t *np = data; |
2367 | 2446 |