Dennis J.
January 12, 2010 09:24PM
Hi,
so I'm making my first steps with developing a nginx module. As a starting
point I took the addition filter module replaced "addition" with
"mmaddition" everywhere and prepended an "mm" to the configuration
directives to avoid collisions. After doing that I can compile and use this
"new" module. So far so good.

Now I'm trying to prepend a static header to a page but things are not
working as I would expect them to. Here is the code fragment I inserted in
the filter function:

ngx_buf_t *header_buffer;
ngx_chain_t *header_link;

header_buffer->pos = (u_char *) "<!-- Served by Nginx -->";
header_buffer->last = header_buffer->pos + sizeof("<!-- Served by
Nginx -->") - 1;
fprintf(stderr, "filter called: ");
fprintf(stderr, header_buffer->pos);

header_link = ngx_alloc_chain_link(r->pool);
header_link->buf = header_buffer;
header_link->buf->last_buf = 1;
header_link->next = NULL;

ngx_http_set_ctx(r, NULL, ngx_http_mmaddition_filter_module);
return ngx_http_next_body_filter(r, header_link);

The problem is that I get "filter called: <!-- Served by Nginx -->" in the
log and a response code of 200 with wget but no body at all.

I'm aware that this code doesn't really insert anything but simply creates
a new chain_link initialized with a buffer which then get passed on to the
next body_filter.

My question is shouldn't I get "<!-- Served by Nginx -->" as a response
body and if not why not?

(I've written a filter module for apache before so I have some experience
with this kind of bucket brigade/chain_link handling but there is obviously
something I'm missing here.)

Regards,
Dennis

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

filter chain_link problem

Dennis J. January 12, 2010 09:24PM

Re: filter chain_link problem

agentzh January 12, 2010 10:10PM

Re: filter chain_link problem

Dennis J. January 12, 2010 10:52PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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