You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2017/05/23 14:35:22 UTC

[Bug 46969] CustomLog format %m always GET on errors with local ErrorDocument

https://bz.apache.org/bugzilla/show_bug.cgi?id=46969

--- Comment #3 from Petar Bogdanovic <pe...@smokva.net> ---
ErrorDocuments are delivered through internal redirects so we end up
with two requests, the original (POST) and the new request (GET).

When resolving REQUEST_METHOD, you should try to resolve the original
REQUEST_METHOD (which would be %<{REQUEST_METHOD}e in mod_log_config
lingo).  Otherwise it will always resolve to "GET" in case of internal
redirects to some ErrorDocument.

It's different with %m, %m will always be "GET" by design:

httpd-2.4.25/modules/http/http_request.c:
188     else if (custom_response[0] == '/') {
189         const char *error_notes;
190         r->no_local_copy = 1;       /* Do NOT send HTTP_NOT_MODIFIED for
191                                      * error documents! */
192         /*
193          * This redirect needs to be a GET no matter what the original
194          * method was.
195          */
196         apr_table_setn(r->subprocess_env, "REQUEST_METHOD", r->method);
197 
198         /*
199          * Provide a special method for modules to communicate
200          * more informative (than the plain canned) messages to us.
201          * Propagate them to ErrorDocuments via the ERROR_NOTES variable:
202          */
203         if ((error_notes = apr_table_get(r->notes,
204                                          "error-notes")) != NULL) {
205             apr_table_setn(r->subprocess_env, "ERROR_NOTES", error_notes);
206         }
207         r->method = "GET";
208         r->method_number = M_GET;
209         ap_internal_redirect(custom_response, r);
210         return;
211     }

Here, apr_die_r saves the original method into REQUEST_METHOD before
resetting method/method_number to "GET"/M_GET and the comment before
apr_table_setn indicates that this is done on purpose.

So if you need the original method, use %<{REQUEST_METHOD}e instead of %m.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org