Mercurial > hg > nginx
comparison src/http/modules/ngx_http_proxy_module.c @ 7220:20f139e9ffa8
Generic subrequests in memory.
Previously, only the upstream response body could be accessed with the
NGX_HTTP_SUBREQUEST_IN_MEMORY feature. Now any response body from a subrequest
can be saved in a memory buffer. It is available as a single buffer in r->out
and the buffer size is configured by the subrequest_output_buffer_size
directive.
Upstream, proxy and fastcgi code used to handle the old-style feature is
removed.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 28 Feb 2018 16:56:58 +0300 |
parents | e8e19f5e0b8b |
children | 06cf0c4b8618 |
comparison
equal
deleted
inserted
replaced
7219:d0d32b33167d | 7220:20f139e9ffa8 |
---|---|
2317 | 2317 |
2318 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | 2318 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
2319 "upstream sent invalid chunked response"); | 2319 "upstream sent invalid chunked response"); |
2320 | 2320 |
2321 return NGX_ERROR; | 2321 return NGX_ERROR; |
2322 } | |
2323 | |
2324 /* provide continuous buffer for subrequests in memory */ | |
2325 | |
2326 if (r->subrequest_in_memory) { | |
2327 | |
2328 cl = u->out_bufs; | |
2329 | |
2330 if (cl) { | |
2331 buf->pos = cl->buf->pos; | |
2332 } | |
2333 | |
2334 buf->last = buf->pos; | |
2335 | |
2336 for (cl = u->out_bufs; cl; cl = cl->next) { | |
2337 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2338 "http proxy in memory %p-%p %O", | |
2339 cl->buf->pos, cl->buf->last, ngx_buf_size(cl->buf)); | |
2340 | |
2341 if (buf->last == cl->buf->pos) { | |
2342 buf->last = cl->buf->last; | |
2343 continue; | |
2344 } | |
2345 | |
2346 buf->last = ngx_movemem(buf->last, cl->buf->pos, | |
2347 cl->buf->last - cl->buf->pos); | |
2348 | |
2349 cl->buf->pos = buf->last - (cl->buf->last - cl->buf->pos); | |
2350 cl->buf->last = buf->last; | |
2351 } | |
2352 } | 2322 } |
2353 | 2323 |
2354 return NGX_OK; | 2324 return NGX_OK; |
2355 } | 2325 } |
2356 | 2326 |