[nginx] svn commit: r4922 - trunk/src/http
mdounin at mdounin.ru
mdounin at mdounin.ru
Wed Nov 21 00:55:06 UTC 2012
Author: mdounin
Date: 2012-11-21 00:55:06 +0000 (Wed, 21 Nov 2012)
New Revision: 4922
URL: http://trac.nginx.org/nginx/changeset/4922/nginx
Log:
Request body: $request_body variable generalization.
The $request_body variable was assuming there can't be more than two
buffers. While this is currently true due to request body reading
implementation details, this is not a good thing to depend on and may
change in the future.
Modified:
trunk/src/http/ngx_http_variables.c
Modified: trunk/src/http/ngx_http_variables.c
===================================================================
--- trunk/src/http/ngx_http_variables.c 2012-11-21 00:54:01 UTC (rev 4921)
+++ trunk/src/http/ngx_http_variables.c 2012-11-21 00:55:06 UTC (rev 4922)
@@ -1767,7 +1767,7 @@
{
u_char *p;
size_t len;
- ngx_buf_t *buf, *next;
+ ngx_buf_t *buf;
ngx_chain_t *cl;
if (r->request_body == NULL
@@ -1792,18 +1792,26 @@
return NGX_OK;
}
- next = cl->next->buf;
- len = (buf->last - buf->pos) + (next->last - next->pos);
+ len = buf->last - buf->pos;
+ cl = cl->next;
+ for ( /* void */ ; cl; cl = cl->next) {
+ buf = cl->buf;
+ len += buf->last - buf->pos;
+ }
+
p = ngx_pnalloc(r->pool, len);
if (p == NULL) {
return NGX_ERROR;
}
v->data = p;
+ cl = r->request_body->bufs;
- p = ngx_cpymem(p, buf->pos, buf->last - buf->pos);
- ngx_memcpy(p, next->pos, next->last - next->pos);
+ for ( /* void */ ; cl; cl = cl->next) {
+ buf = cl->buf;
+ p = ngx_cpymem(p, buf->pos, buf->last - buf->pos);
+ }
v->len = len;
v->valid = 1;
More information about the nginx-devel
mailing list