Welcome! Log In Create A New Profile

Advanced

Insert

Witold Filipczyk
October 05, 2010 05:30AM
Hi,
There is a body filter and:
in - first "chain"
b - current buf
u_char *p - position of '>'
cl - current "chain"
I want to insert the header after '>'.
ctx->header is u_char *
ctx->header_len is length

Code:
cl2 = ngx_alloc_chain_link(r->pool);
if (!cl2) {
return NGX_ERROR;
}
header = ngx_alloc_buf(r->pool);
if (!header) {
return NGX_ERROR;
}
header->pos = ctx->header;
header->last = ctx->header + ctx->header_len;
header->memory = 1;
cl2->buf = header;

if (p == b->last - 1) {
cl2->next = cl->next;
cl->next = cl2;
ctx->state = NGX_LAYOUT_WAS_BODY;
return ngx_http_next_body_filter(r, in);
}
buf = ngx_alloc_buf(r->pool);
if (!buf) {
return NGX_ERROR;
}
cl3 = ngx_alloc_chain_link(r->pool);
if (!cl3) {
return NGX_ERROR;
}
buf->pos = p + 1;
buf->last = b->last;
b->last = p + 1;
cl3->buf = buf;
cl3->next = cl->next;
cl2->next = cl3;
cl->next = cl2;
ctx->state = NGX_LAYOUT_WAS_BODY;
return ngx_http_next_body_filter(r, in);

Is it correct?
I mean spliting b into two pieces.
Or something must be added to this code?

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

Insert

Witold Filipczyk 1744 October 05, 2010 05:30AM



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

Online Users

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