diff 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
line wrap: on
line diff
--- a/ngx_http_auth_request_module.c
+++ b/ngx_http_auth_request_module.c
@@ -190,7 +190,16 @@ ngx_http_auth_request_handler(ngx_http_r
         return NGX_ERROR;
     }
 
-    sr->discard_body = 1;
+    /*
+     * allocate fake request body to avoid attempts to read it and to make
+     * sure real body file (if already read) won't be closed by upstream
+     */
+
+    sr->request_body = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
+    if (sr->request_body == NULL) {
+        return NGX_ERROR;
+    }
+
     sr->header_only = 1;
 
     ctx->subrequest = sr;