Welcome! Log In Create A New Profile

Advanced

How to unset header in nginx module

Tsukasa Hamano
March 16, 2012 01:00PM
Hi,

I'd like to delete particular headers_in like a apr_table_unset() in
request handler of my module.

I wrote examples from the article:
http://wiki.nginx.org/HeadersManagement

static void unset_header(ngx_http_request_t *r, u_char *key){
ngx_list_part_t *part;
ngx_table_elt_t *h;
ngx_uint_t i;
size_t len = strlen((char *)key);

part = &r->headers_in.headers.part;
h = part->elts;
for (i = 0; ; i++) {
if (i >= part->nelts) {
if (part->next == NULL) {
break;
}
part = part->next;
h = part->elts;
i = 0;
}
if (len != h[i].key.len || ngx_strcasecmp(key, h[i].key.data) != 0) {
h[i].hash = 0;
h[i].key.len = 0;
h[i].key.data = NULL;
h[i].value.len = 0;
h[i].value.data = NULL;
h[i].lowcase_key = NULL;
}
}
}

But this code send empty header(only colon) line to backend.
like this:

:

Should I reconstruct list of headers_in.headers?
Or, should I modify http main module that to avoid sending null header?
Or, Is there any better(faster) way?

Thank you.

--
Open Source Solution Technology Corporation
Tsukasa Hamano <hamano@osstech.co.jp>
fingerprint = 2285 2111 6D34 3816 3C2E A5B9 16BE D101 6069 BE55
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to unset header in nginx module

Tsukasa Hamano March 16, 2012 01:00PM

Re: How to unset header in nginx module

Maxim Dounin March 16, 2012 01:34PM

Re: How to unset header in nginx module

Tsukasa Hamano March 17, 2012 04:36AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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