Welcome! Log In Create A New Profile

Advanced

Re: [nginx] slice module issue

June 20, 2017 01:24PM
I hope slice module can satisfy customer requirements.

Now the key point is users want to control the behavior of slice.
And this is common.

Here's the patch, take a look please!

diff -r 5e05118678af src/http/modules/ngx_http_slice_filter_module.c
--- a/src/http/modules/ngx_http_slice_filter_module.c Mon May 29 23:33:38
2017 +0300
+++ b/src/http/modules/ngx_http_slice_filter_module.c Tue Jun 20 13:17:17
2017 -0400
@@ -12,6 +12,7 @@

typedef struct {
size_t size;
+ ngx_flag_t always;
} ngx_http_slice_loc_conf_t;


@@ -57,6 +58,13 @@
offsetof(ngx_http_slice_loc_conf_t, size),
NULL },

+ { ngx_string("slice_always"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_slice_loc_conf_t, always),
+ NULL },
+
ngx_null_command
};

@@ -389,6 +397,7 @@
ngx_http_variable_value_t *v, uintptr_t data)
{
u_char *p;
+ off_t start;
ngx_http_slice_ctx_t *ctx;
ngx_http_slice_loc_conf_t *slcf;

@@ -407,6 +416,12 @@
return NGX_OK;
}

+ start = ngx_http_slice_get_start(r);
+ if (start == -1 && slcf->always == 0) {
+ v->not_found = 1;
+ return NGX_OK;
+ }
+
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_slice_ctx_t));
if (ctx == NULL) {
return NGX_ERROR;
@@ -419,7 +434,7 @@
return NGX_ERROR;
}

- ctx->start = slcf->size * (ngx_http_slice_get_start(r) /
slcf->size);
+ ctx->start = slcf->size * (start / slcf->size);

ctx->range.data = p;
ctx->range.len = ngx_sprintf(p, "bytes=%O-%O", ctx->start,
@@ -445,7 +460,7 @@
ngx_table_elt_t *h;

if (r->headers_in.if_range) {
- return 0;
+ return -1;
}

h = r->headers_in.range;
@@ -454,13 +469,13 @@
|| h->value.len < 7
|| ngx_strncasecmp(h->value.data, (u_char *) "bytes=", 6) != 0)
{
- return 0;
+ return -1;
}

p = h->value.data + 6;

if (ngx_strchr(p, ',')) {
- return 0;
+ return -1;
}

while (*p == ' ') { p++; }
@@ -476,7 +491,7 @@

while (*p >= '0' && *p <= '9') {
if (start >= cutoff && (start > cutoff || *p - '0' > cutlim)) {
- return 0;
+ return -1;
}

start = start * 10 + *p++ - '0';
@@ -497,6 +512,7 @@
}

slcf->size = NGX_CONF_UNSET_SIZE;
+ slcf->always = NGX_CONF_UNSET;

return slcf;
}
@@ -509,6 +525,7 @@
ngx_http_slice_loc_conf_t *conf = child;

ngx_conf_merge_size_value(conf->size, prev->size, 0);
+ ngx_conf_merge_value(conf->always, prev->always, 1);

return NGX_CONF_OK;
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] slice module issue

karton 900 June 19, 2017 02:26PM

Re: [nginx] slice module issue

Roman Arutyunyan 348 June 20, 2017 08:10AM

Re: [nginx] slice module issue

karton 418 June 20, 2017 08:44AM

Re: [nginx] slice module issue

Roman Arutyunyan 300 June 20, 2017 09:36AM

Re: [nginx] slice module issue

karton 384 June 20, 2017 11:24AM

Re: [nginx] slice module issue

karton 369 June 20, 2017 11:48AM

Re: [nginx] slice module issue

Roman Arutyunyan 321 June 20, 2017 12:32PM

Re: [nginx] slice module issue

karton 382 June 20, 2017 12:46PM

Re: [nginx] slice module issue

karton 408 June 20, 2017 01:24PM

Re: [nginx] slice module issue

Roman Arutyunyan 334 June 20, 2017 02:46PM

Re: [nginx] slice module issue

karton 434 June 20, 2017 03:12PM



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

Online Users

Guests: 299
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready