comparison ngx_http_auth_request_module.c @ 10:2b95417a1715

Auth request: fix body handling again. Setting r->discard_body is wrong way to go as it causes lingering timer to be armed on subrequest finalization. Create fake body instead. This also allows to protect real body file from being closed in case it was already read. Though it doesn't matter now as we set r->header_only and relevant code in ngx_http_upstream_send_response() isn't reached.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 24 Mar 2010 07:23:22 +0300
parents fb05a061532c
children d4c131d13048
comparison
equal deleted inserted replaced
9:4385a10a836f 10:2b95417a1715
188 != NGX_OK) 188 != NGX_OK)
189 { 189 {
190 return NGX_ERROR; 190 return NGX_ERROR;
191 } 191 }
192 192
193 sr->discard_body = 1; 193 /*
194 * allocate fake request body to avoid attempts to read it and to make
195 * sure real body file (if already read) won't be closed by upstream
196 */
197
198 sr->request_body = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
199 if (sr->request_body == NULL) {
200 return NGX_ERROR;
201 }
202
194 sr->header_only = 1; 203 sr->header_only = 1;
195 204
196 ctx->subrequest = sr; 205 ctx->subrequest = sr;
197 206
198 ngx_http_set_ctx(r, ctx, ngx_http_auth_request_module); 207 ngx_http_set_ctx(r, ctx, ngx_http_auth_request_module);