Mercurial > hg > nginx
comparison src/http/ngx_http_variables.c @ 4921:fbc0791bebb2
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 21 Nov 2012 00:55:06 +0000 |
parents | 002f2c783d7c |
children | ec7d97006a30 |
comparison
equal
deleted
inserted
replaced
4920:812c4765c954 | 4921:fbc0791bebb2 |
---|---|
1765 ngx_http_variable_request_body(ngx_http_request_t *r, | 1765 ngx_http_variable_request_body(ngx_http_request_t *r, |
1766 ngx_http_variable_value_t *v, uintptr_t data) | 1766 ngx_http_variable_value_t *v, uintptr_t data) |
1767 { | 1767 { |
1768 u_char *p; | 1768 u_char *p; |
1769 size_t len; | 1769 size_t len; |
1770 ngx_buf_t *buf, *next; | 1770 ngx_buf_t *buf; |
1771 ngx_chain_t *cl; | 1771 ngx_chain_t *cl; |
1772 | 1772 |
1773 if (r->request_body == NULL | 1773 if (r->request_body == NULL |
1774 || r->request_body->bufs == NULL | 1774 || r->request_body->bufs == NULL |
1775 || r->request_body->temp_file) | 1775 || r->request_body->temp_file) |
1790 v->data = buf->pos; | 1790 v->data = buf->pos; |
1791 | 1791 |
1792 return NGX_OK; | 1792 return NGX_OK; |
1793 } | 1793 } |
1794 | 1794 |
1795 next = cl->next->buf; | 1795 len = buf->last - buf->pos; |
1796 len = (buf->last - buf->pos) + (next->last - next->pos); | 1796 cl = cl->next; |
1797 | |
1798 for ( /* void */ ; cl; cl = cl->next) { | |
1799 buf = cl->buf; | |
1800 len += buf->last - buf->pos; | |
1801 } | |
1797 | 1802 |
1798 p = ngx_pnalloc(r->pool, len); | 1803 p = ngx_pnalloc(r->pool, len); |
1799 if (p == NULL) { | 1804 if (p == NULL) { |
1800 return NGX_ERROR; | 1805 return NGX_ERROR; |
1801 } | 1806 } |
1802 | 1807 |
1803 v->data = p; | 1808 v->data = p; |
1804 | 1809 cl = r->request_body->bufs; |
1805 p = ngx_cpymem(p, buf->pos, buf->last - buf->pos); | 1810 |
1806 ngx_memcpy(p, next->pos, next->last - next->pos); | 1811 for ( /* void */ ; cl; cl = cl->next) { |
1812 buf = cl->buf; | |
1813 p = ngx_cpymem(p, buf->pos, buf->last - buf->pos); | |
1814 } | |
1807 | 1815 |
1808 v->len = len; | 1816 v->len = len; |
1809 v->valid = 1; | 1817 v->valid = 1; |
1810 v->no_cacheable = 0; | 1818 v->no_cacheable = 0; |
1811 v->not_found = 0; | 1819 v->not_found = 0; |