Content does not get replaced
Adelino Monteiro
adelino at ainou.net
Mon May 30 22:35:17 MSD 2011
Hello,
I'm writing my first module (actually a copy from mod_strip with some simple
modifications)
I have this simple function that for testing purposes should simply make a
simple substitution of all chars to A. I used gdb and chain_link->buf->start
indeed has all the characters replaced with A. However the output in the
end is the original file without any other modification.
Could someone shed some light on this mistery?
Thanks
AM
static ngx_int_t
ngx_http_strip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
ngx_http_strip_ctx_t *ctx;
ngx_chain_t *chain_link;
u_char *reader;
u_char *writer;
ngx_log_t *log;
log = r->connection->log;
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "In strip strip body filter 1
");
ctx = ngx_http_get_module_ctx(r, ngx_http_strip_filter_module);
if (ctx == NULL) {
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "In strip strip body
filter 2 ");
return ngx_http_next_body_filter(r, in);
}
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "In strip strip body filter 3
");
for (chain_link = in; chain_link; chain_link = chain_link->next) {
for (writer = chain_link->buf->pos, reader = chain_link->buf->pos;
reader < chain_link->buf->last; reader++) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "w: \"%c\"",
*reader);
*reader = 'A' ;
if (reader < chain_link->buf->last)
*writer++ = *reader;
}
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "In strip_body_filter
writer: \"%s\"", writer);
chain_link->buf->last = writer;
}
return ngx_http_next_body_filter(r, in);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-devel/attachments/20110530/e0d43cda/attachment.html>
More information about the nginx-devel
mailing list