Welcome! Log In Create A New Profile

Advanced

[njs] HTTP: improved setting of special response headers.

Dmitry Volyntsev
February 06, 2019 12:22PM
details: https://hg.nginx.org/njs/rev/9bd38c6bf046
branches:
changeset: 765:9bd38c6bf046
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed Feb 06 19:22:18 2019 +0300
description:
HTTP: improved setting of special response headers.

diffstat:

nginx/ngx_http_js_module.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)

diffs (47 lines):

diff -r 342aa58f4e65 -r 9bd38c6bf046 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c Wed Feb 06 15:50:03 2019 +0300
+++ b/nginx/ngx_http_js_module.c Wed Feb 06 19:22:18 2019 +0300
@@ -934,6 +934,18 @@ ngx_http_js_ext_set_header_out(njs_vm_t
r = (ngx_http_request_t *) obj;
v = (nxt_str_t *) data;

+ if (v->length == nxt_length("Content-Type")
+ && ngx_strncasecmp(v->start, (u_char *) "Content-Type",
+ v->length) == 0)
+ {
+ r->headers_out.content_type.len = value->length;
+ r->headers_out.content_type_len = r->headers_out.content_type.len;
+ r->headers_out.content_type.data = value->start;
+ r->headers_out.content_type_lowcase = NULL;
+
+ return NJS_OK;
+ }
+
h = ngx_http_js_get_header(&r->headers_out.headers.part, v->start,
v->length);

@@ -965,12 +977,21 @@ ngx_http_js_ext_set_header_out(njs_vm_t
h->value.data = p;
h->value.len = value->length;

- if (h->key.len == nxt_length("Content-Length")
- && ngx_strncasecmp(h->key.data, (u_char *) "Content-Length",
- nxt_length("Content-Length")) == 0)
+ if (v->length == nxt_length("Content-Encoding")
+ && ngx_strncasecmp(v->start, (u_char *) "Content-Encoding",
+ v->length) == 0)
+ {
+ r->headers_out.content_encoding = h;
+ }
+
+ if (v->length == nxt_length("Content-Length")
+ && ngx_strncasecmp(v->start, (u_char *) "Content-Length",
+ v->length) == 0)
{
n = ngx_atoi(value->start, value->length);
if (n == NGX_ERROR) {
+ h->hash = 0;
+ njs_vm_error(vm, "failed converting argument to integer");
return NJS_ERROR;
}

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

[njs] HTTP: improved setting of special response headers.

Dmitry Volyntsev 123 February 06, 2019 12:22PM



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

Online Users

Guests: 87
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