Mercurial > hg > nginx-quic
comparison src/http/ngx_http_core_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 | 46ebff8c6396 |
children | 7f955d3b9a0d |
comparison
equal
deleted
inserted
replaced
7219:d0d32b33167d | 7220:20f139e9ffa8 |
---|---|
397 ngx_conf_set_size_slot, | 397 ngx_conf_set_size_slot, |
398 NGX_HTTP_LOC_CONF_OFFSET, | 398 NGX_HTTP_LOC_CONF_OFFSET, |
399 offsetof(ngx_http_core_loc_conf_t, sendfile_max_chunk), | 399 offsetof(ngx_http_core_loc_conf_t, sendfile_max_chunk), |
400 NULL }, | 400 NULL }, |
401 | 401 |
402 { ngx_string("subrequest_output_buffer_size"), | |
403 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
404 ngx_conf_set_size_slot, | |
405 NGX_HTTP_LOC_CONF_OFFSET, | |
406 offsetof(ngx_http_core_loc_conf_t, subrequest_output_buffer_size), | |
407 NULL }, | |
408 | |
402 { ngx_string("aio"), | 409 { ngx_string("aio"), |
403 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 410 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
404 ngx_http_core_set_aio, | 411 ngx_http_core_set_aio, |
405 NGX_HTTP_LOC_CONF_OFFSET, | 412 NGX_HTTP_LOC_CONF_OFFSET, |
406 0, | 413 0, |
2235 "request reference counter overflow " | 2242 "request reference counter overflow " |
2236 "while processing \"%V\"", uri); | 2243 "while processing \"%V\"", uri); |
2237 return NGX_ERROR; | 2244 return NGX_ERROR; |
2238 } | 2245 } |
2239 | 2246 |
2247 if (r->subrequest_in_memory) { | |
2248 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
2249 "nested in-memory subrequest \"%V\"", uri); | |
2250 return NGX_ERROR; | |
2251 } | |
2252 | |
2240 sr = ngx_pcalloc(r->pool, sizeof(ngx_http_request_t)); | 2253 sr = ngx_pcalloc(r->pool, sizeof(ngx_http_request_t)); |
2241 if (sr == NULL) { | 2254 if (sr == NULL) { |
2242 return NGX_ERROR; | 2255 return NGX_ERROR; |
2243 } | 2256 } |
2244 | 2257 |
2315 sr->write_event_handler = ngx_http_handler; | 2328 sr->write_event_handler = ngx_http_handler; |
2316 | 2329 |
2317 sr->variables = r->variables; | 2330 sr->variables = r->variables; |
2318 | 2331 |
2319 sr->log_handler = r->log_handler; | 2332 sr->log_handler = r->log_handler; |
2333 | |
2334 if (sr->subrequest_in_memory) { | |
2335 sr->filter_need_in_memory = 1; | |
2336 } | |
2320 | 2337 |
2321 if (!sr->background) { | 2338 if (!sr->background) { |
2322 if (c->data == r && r->postponed == NULL) { | 2339 if (c->data == r && r->postponed == NULL) { |
2323 c->data = sr; | 2340 c->data = sr; |
2324 } | 2341 } |
3354 clcf->client_body_in_file_only = NGX_CONF_UNSET_UINT; | 3371 clcf->client_body_in_file_only = NGX_CONF_UNSET_UINT; |
3355 clcf->client_body_in_single_buffer = NGX_CONF_UNSET; | 3372 clcf->client_body_in_single_buffer = NGX_CONF_UNSET; |
3356 clcf->internal = NGX_CONF_UNSET; | 3373 clcf->internal = NGX_CONF_UNSET; |
3357 clcf->sendfile = NGX_CONF_UNSET; | 3374 clcf->sendfile = NGX_CONF_UNSET; |
3358 clcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE; | 3375 clcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE; |
3376 clcf->subrequest_output_buffer_size = NGX_CONF_UNSET_SIZE; | |
3359 clcf->aio = NGX_CONF_UNSET; | 3377 clcf->aio = NGX_CONF_UNSET; |
3360 clcf->aio_write = NGX_CONF_UNSET; | 3378 clcf->aio_write = NGX_CONF_UNSET; |
3361 #if (NGX_THREADS) | 3379 #if (NGX_THREADS) |
3362 clcf->thread_pool = NGX_CONF_UNSET_PTR; | 3380 clcf->thread_pool = NGX_CONF_UNSET_PTR; |
3363 clcf->thread_pool_value = NGX_CONF_UNSET_PTR; | 3381 clcf->thread_pool_value = NGX_CONF_UNSET_PTR; |
3576 prev->client_body_in_single_buffer, 0); | 3594 prev->client_body_in_single_buffer, 0); |
3577 ngx_conf_merge_value(conf->internal, prev->internal, 0); | 3595 ngx_conf_merge_value(conf->internal, prev->internal, 0); |
3578 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0); | 3596 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0); |
3579 ngx_conf_merge_size_value(conf->sendfile_max_chunk, | 3597 ngx_conf_merge_size_value(conf->sendfile_max_chunk, |
3580 prev->sendfile_max_chunk, 0); | 3598 prev->sendfile_max_chunk, 0); |
3599 ngx_conf_merge_size_value(conf->subrequest_output_buffer_size, | |
3600 prev->subrequest_output_buffer_size, | |
3601 (size_t) ngx_pagesize); | |
3581 ngx_conf_merge_value(conf->aio, prev->aio, NGX_HTTP_AIO_OFF); | 3602 ngx_conf_merge_value(conf->aio, prev->aio, NGX_HTTP_AIO_OFF); |
3582 ngx_conf_merge_value(conf->aio_write, prev->aio_write, 0); | 3603 ngx_conf_merge_value(conf->aio_write, prev->aio_write, 0); |
3583 #if (NGX_THREADS) | 3604 #if (NGX_THREADS) |
3584 ngx_conf_merge_ptr_value(conf->thread_pool, prev->thread_pool, NULL); | 3605 ngx_conf_merge_ptr_value(conf->thread_pool, prev->thread_pool, NULL); |
3585 ngx_conf_merge_ptr_value(conf->thread_pool_value, prev->thread_pool_value, | 3606 ngx_conf_merge_ptr_value(conf->thread_pool_value, prev->thread_pool_value, |