Mercurial > hg > nginx-quic
comparison src/http/ngx_http_variables.c @ 4957:7556a7acb14f stable-1.2
Merge of r4921, r4922, r4923, r4924, r4925: request body fixes.
*) Request body: fixed "501 Not Implemented" error handling.
It is not about "Method" but a generic message, and is expected to be used
e.g. if specified Transfer-Encoding is not supported. Fixed message to
match RFC 2616.
Additionally, disable keepalive on such errors as we won't be able to read
request body correctly if we don't understand Transfer-Encoding used.
*) 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.
*) Request body: code duplication reduced, no functional changes.
The r->request_body_in_file_only with empty body case is now handled in
ngx_http_write_request_body().
*) Request body: fixed socket leak on errors.
The r->main->count reference counter was always incremented in
ngx_http_read_client_request_body(), while it is only needs to be
incremented on positive returns.
*) Request body: properly handle events while discarding body.
An attempt to call ngx_handle_read_event() before actually reading
data from a socket might result in read event being disabled, which is
wrong. Catched by body.t test on Solaris.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 11 Dec 2012 13:18:50 +0000 |
parents | 9ab61d17794f |
children | 05beaa2d87b3 |
comparison
equal
deleted
inserted
replaced
4956:bbcaeccbd928 | 4957:7556a7acb14f |
---|---|
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; |