comparison src/http/modules/ngx_http_uwsgi_module.c @ 3565:1e86f0ac9a44

uwsgi_store
author Igor Sysoev <igor@sysoev.ru>
date Fri, 04 Jun 2010 11:31:01 +0000
parents 3da009cc90f3
children b81d44244cb1
comparison
equal deleted inserted replaced
3564:3da009cc90f3 3565:1e86f0ac9a44
57 static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, 57 static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
58 void *child); 58 void *child);
59 59
60 static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, 60 static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
61 void *conf); 61 void *conf);
62 static char *ngx_http_uwsgi_store(ngx_conf_t *cf, ngx_command_t *cmd,
63 void *conf);
62 64
63 65
64 static ngx_conf_num_bounds_t ngx_http_uwsgi_modifier_bounds = { 66 static ngx_conf_num_bounds_t ngx_http_uwsgi_modifier_bounds = {
65 ngx_conf_check_num_bounds, 0, 255 67 ngx_conf_check_num_bounds, 0, 255
66 }; 68 };
108 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 110 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
109 ngx_conf_set_num_slot, 111 ngx_conf_set_num_slot,
110 NGX_HTTP_LOC_CONF_OFFSET, 112 NGX_HTTP_LOC_CONF_OFFSET,
111 offsetof(ngx_http_uwsgi_loc_conf_t, modifier2), 113 offsetof(ngx_http_uwsgi_loc_conf_t, modifier2),
112 &ngx_http_uwsgi_modifier_bounds }, 114 &ngx_http_uwsgi_modifier_bounds },
115
116 { ngx_string("uwsgi_store"),
117 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
118 ngx_http_uwsgi_store,
119 NGX_HTTP_LOC_CONF_OFFSET,
120 0,
121 NULL },
122
123 { ngx_string("uwsgi_store_access"),
124 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,
125 ngx_conf_set_access_slot,
126 NGX_HTTP_LOC_CONF_OFFSET,
127 offsetof(ngx_http_uwsgi_loc_conf_t, upstream.store_access),
128 NULL },
113 129
114 { ngx_string("uwsgi_ignore_client_abort"), 130 { ngx_string("uwsgi_ignore_client_abort"),
115 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, 131 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
116 ngx_conf_set_flag_slot, 132 ngx_conf_set_flag_slot,
117 NGX_HTTP_LOC_CONF_OFFSET, 133 NGX_HTTP_LOC_CONF_OFFSET,
1449 clcf->auto_redirect = 1; 1465 clcf->auto_redirect = 1;
1450 } 1466 }
1451 1467
1452 return NGX_CONF_OK; 1468 return NGX_CONF_OK;
1453 } 1469 }
1470
1471
1472 static char *
1473 ngx_http_uwsgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1474 {
1475 ngx_http_uwsgi_loc_conf_t *uwcf = conf;
1476
1477 ngx_str_t *value;
1478 ngx_http_script_compile_t sc;
1479
1480 if (uwcf->upstream.store != NGX_CONF_UNSET || uwcf->upstream.store_lengths)
1481 {
1482 return "is duplicate";
1483 }
1484
1485 value = cf->args->elts;
1486
1487 if (ngx_strcmp(value[1].data, "on") == 0) {
1488 uwcf->upstream.store = 1;
1489 return NGX_CONF_OK;
1490 }
1491
1492 if (ngx_strcmp(value[1].data, "off") == 0) {
1493 uwcf->upstream.store = 0;
1494 return NGX_CONF_OK;
1495 }
1496
1497 /* include the terminating '\0' into script */
1498 value[1].len++;
1499
1500 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
1501
1502 sc.cf = cf;
1503 sc.source = &value[1];
1504 sc.lengths = &uwcf->upstream.store_lengths;
1505 sc.values = &uwcf->upstream.store_values;
1506 sc.variables = ngx_http_script_variables_count(&value[1]);;
1507 sc.complete_lengths = 1;
1508 sc.complete_values = 1;
1509
1510 if (ngx_http_script_compile(&sc) != NGX_OK) {
1511 return NGX_CONF_ERROR;
1512 }
1513
1514 return NGX_CONF_OK;
1515 }