Welcome! Log In Create A New Profile

Advanced

limit_rate_after support variables

Miroslav Novy
August 14, 2018 04:24AM
# HG changeset patch
# User Miroslav Nový <miranovy@gmail.com>
# Date 1534234559 0
# Tue Aug 14 08:15:59 2018 +0000
# Node ID 1a8327b50f7844cbe68226f54de60632189327f4
# Parent 70c6b08973a02551612da4a4273757dc77c70ae2
limit_rate_after support variables

Example of use:
location / {
root /var/www/default/;
index index.html index.htm;

set $my_limit_rate_after 2m;

limit_rate_after $my_limit_rate_after;
limit_rate 2k;

access_by_lua_block {
ngx.var.my_limit_rate_after = '10m'
}

}

diff -r 70c6b08973a0 -r 1a8327b50f78 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c Fri Aug 10 21:54:46 2018 +0300
+++ b/src/http/ngx_http_core_module.c Tue Aug 14 08:15:59 2018 +0000
@@ -487,7 +487,7 @@
{ ngx_string("limit_rate_after"),

NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
+ ngx_http_set_complex_value_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_core_loc_conf_t, limit_rate_after),
NULL },
@@ -3364,6 +3364,7 @@
* clcf->alias = 0;
* clcf->gzip_proxied = 0;
* clcf->keepalive_disable = 0;
+ * clcf->limit_rate_after = NULL;
*/

clcf->client_max_body_size = NGX_CONF_UNSET;
@@ -3393,7 +3394,6 @@
clcf->send_lowat = NGX_CONF_UNSET_SIZE;
clcf->postpone_output = NGX_CONF_UNSET_SIZE;
clcf->limit_rate = NGX_CONF_UNSET_SIZE;
- clcf->limit_rate_after = NGX_CONF_UNSET_SIZE;
clcf->keepalive_timeout = NGX_CONF_UNSET_MSEC;
clcf->keepalive_header = NGX_CONF_UNSET;
clcf->keepalive_requests = NGX_CONF_UNSET_UINT;
@@ -3623,8 +3623,8 @@
ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output,
1460);
ngx_conf_merge_size_value(conf->limit_rate, prev->limit_rate, 0);
- ngx_conf_merge_size_value(conf->limit_rate_after,
prev->limit_rate_after,
- 0);
+ ngx_conf_merge_ptr_value(conf->limit_rate_after,
prev->limit_rate_after,
+ NULL);
ngx_conf_merge_msec_value(conf->keepalive_timeout,
prev->keepalive_timeout, 75000);
ngx_conf_merge_sec_value(conf->keepalive_header,
diff -r 70c6b08973a0 -r 1a8327b50f78 src/http/ngx_http_core_module.h
--- a/src/http/ngx_http_core_module.h Fri Aug 10 21:54:46 2018 +0300
+++ b/src/http/ngx_http_core_module.h Tue Aug 14 08:15:59 2018 +0000
@@ -351,7 +351,7 @@
size_t send_lowat; /* send_lowat */
size_t postpone_output; /* postpone_output */
size_t limit_rate; /* limit_rate */
- size_t limit_rate_after; /* limit_rate_after */
+ ngx_http_complex_value_t *limit_rate_after; /*
limit_rate_after */
size_t sendfile_max_chunk; /* sendfile_max_chunk */
size_t read_ahead; /* read_ahead */
size_t subrequest_output_buffer_size;
diff -r 70c6b08973a0 -r 1a8327b50f78 src/http/ngx_http_write_filter_module.c
--- a/src/http/ngx_http_write_filter_module.c Fri Aug 10 21:54:46 2018 +0300
+++ b/src/http/ngx_http_write_filter_module.c Tue Aug 14 08:15:59 2018 +0000
@@ -220,7 +220,26 @@

if (r->limit_rate) {
if (r->limit_rate_after == 0) {
- r->limit_rate_after = clcf->limit_rate_after;
+ r->limit_rate_after = 0;
+
+ if (clcf->limit_rate_after != NULL) {
+ ngx_str_t res;
+ size_t st;
+
+ if (ngx_http_complex_value(r, clcf->limit_rate_after, &res)
+ != NGX_OK)
+ {
+ return NGX_ERROR;
+ }
+
+ st = ngx_parse_size(&res);
+ if (st != (size_t) NGX_ERROR) {
+ r->limit_rate_after = st;
+ } else {
+ ngx_log_error(NGX_LOG_ALERT, c->log, 0,
+ "limit_rate_after has bad value");
+ }
+ }
}

limit = (off_t) r->limit_rate * (ngx_time() - r->start_sec + 1)
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

limit_rate_after support variables

Miroslav Novy 232 August 14, 2018 04:24AM

Re: limit_rate_after support variables

ru@nginx.com 38 August 27, 2018 07:30AM

Re: limit_rate_after support variables

Miroslav Novy 53 August 27, 2018 09:38AM

Re: limit_rate_after support variables

ru@nginx.com 42 August 27, 2018 12:02PM

Re: limit_rate_after support variables

Miroslav Novy 36 August 28, 2018 03:24AM

Re: limit_rate_after support variables

ru@nginx.com 38 August 29, 2018 07:44AM

Re: limit_rate_after support variables

Miroslav Novy 44 August 30, 2018 03:02AM

Re: limit_rate_after support variables

Miroslav Novy 36 October 17, 2018 06:50AM

Re: limit_rate_after support variables

ru@nginx.com 13 November 20, 2018 09:12AM

Re: limit_rate_after support variables

Miroslav Novy 9 November 21, 2018 06:12AM

Re: limit_rate_after support variables

Miroslav Novy 18 November 21, 2018 09:52AM

Re: limit_rate_after support variables

ru@nginx.com 9 December 06, 2018 09:46AM

Re: limit_rate_after support variables

Miroslav Novy 5 December 10, 2018 08:32AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 83
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready