filter chain_link problem
Dennis J.
dennisml at conversis.de
Wed Jan 13 05:17:22 MSK 2010
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
More information about the nginx
mailing list