Bug: custom error_page doesn't work for HTTP 413 (content too large)
Peter Vandenberk
pvdb at bragster.com
Mon Aug 31 21:25:45 MSD 2009
Hi Igor,
Igor Sysoev <is at ...> writes:
> The attached patch should fix the bug.
Thanks for the quick reply to my question, and for taking the time
to supply a patch... much appreciated!
The patch works like a charm... thanks for that! I forgot to mention
that we are running the "legacy" 0.6.xx version of nginx, so I have
attached a slightly modified version of your patch with the correct
diff context (esp. line numbers) for that version of the code base.
Igor Sysoev <is at ...> writes:
> However, browsers usually show the 413 error page only after they have sent
> a whole request body. Therefore on slow connection and with large body
> browsers will show some network error or "this page cannot be displayed" page.
Yes, thanks for the heads up... some of our users have indeed reported
that behaviour to us as well, but quite a few also get a proper 413 response,
which is why we are so eager to implement a custom 413 error page.
Thanks again for your time and the patch!
Peter
===
*** src/http/ngx_http_core_module.orig 2009-08-31 18:10:46.000000000 +0100
--- src/http/ngx_http_core_module.c 2009-08-31 18:11:26.000000000 +0100
***************
*** 859,864 ****
--- 859,865 ----
"client intended to send too large body: %O bytes",
r->headers_in.content_length_n);
+ (void) ngx_http_discard_request_body(r);
ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
return NGX_OK;
}
More information about the nginx
mailing list