so I’m making my first steps with developing a nginx module. As a
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
“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
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
Nginx -->") - 1;
fprintf(stderr, "filter called: ");
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: " in
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
a new chain_link initialized with a buffer which then get passed on to
My question is shouldn’t I get “” as a response
body and if not why not?
(I’ve written a filter module for apache before so I have some
with this kind of bucket brigade/chain_link handling but there is
something I’m missing here.)