May 30, 2011 02:36PM
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);
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Content does not get replaced

ainou 1728 May 30, 2011 02:36PM

Re: Content does not get replaced

Maxim Dounin 592 May 30, 2011 06:28PM

Re: Content does not get replaced

ainou 925 May 31, 2011 12:24PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 67
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready