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 2018/03/16 15:20:28 UTC

[Bug 62186] New: ErrorDocument causes POST request getting logged as GET request

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

            Bug ID: 62186
           Summary: ErrorDocument causes POST request getting logged as
                    GET request
           Product: Apache httpd-2
           Version: 2.5-HEAD
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
          Assignee: bugs@httpd.apache.org
          Reporter: micha@lenk.info
  Target Milestone: ---

Created attachment 35777
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35777&action=edit
Preserve request method for non-GET requests with ErrorDocument

If ErrorDocument is used with local files, and a LogFormat is used with "%<m"
to log the original's request method, the logged request method is wrong for
non-GET requests.

After some debugging and reading code I found the core function ap_die_r() to
overwrite the original requests's r->method and r->method_number in the code
path that calls ap_internal_redirect() for generating the response body from
the local file configured with ErrorDocument. Any subsequent access on
r->method will see a GET request, even if the original request was not a GET
request. So, consequently a placeholder of "%<m" used in LogFormat will
generate the string "GET" for all requests. (I assume the intent behind
overwriting r->method and r->method_number is to force the internal redirect
request for the local error document specified with ErrorDocument into a "GET"
request.)

The attached patch fixes that as close as possible, that is right after calling
ap_internal_redirect(), by restoring the original r->method and
r->method_number. At least it fixes the issue for the use case described above,
that is when logging the request method.

The patch is good enough for (ie. it fixes) my use case. Yet, it might still be
slightly incorrect. Any processing that happens within the call of
ap_internal_redirect (modules and so on) will see r->prev->method to be a "GET"
request, even if it was not. So, a better fix might be to extend the
ap_internal_redirect() function signature to contain an explicit request
method, which would obsolete the need to overwrite r->method inside ap_die_r().
But that would mean an API change impacting anything that potentially calls
ap_internal_redirect(). So, this probably can't be done on (i.e. backported to)
the 2.4.x branch.

-- 
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


[Bug 62186] ErrorDocument causes POST request getting logged as GET request

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62186

Eric Covener <co...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |FixedInTrunk

--- Comment #2 from Eric Covener <co...@gmail.com> ---
Thanks Micha, committed to trunk in r1828920 and proposed for 2.4.x.

-- 
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


[Bug 62186] ErrorDocument causes POST request getting logged as GET request

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62186

Micha Lenk <mi...@lenk.info> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable

-- 
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


[Bug 62186] ErrorDocument causes POST request getting logged as GET request

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62186

--- Comment #1 from Micha Lenk <mi...@lenk.info> ---
Created attachment 35778
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35778&action=edit
Changes to httpd-test suite for easier reproduction

I also prepared a change set for the httpd-test suite that can be used to
reproduce the issue fairly easy. See the second attached patch.

-- 
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


[Bug 62186] ErrorDocument causes POST request getting logged as GET request

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62186

nsg-apache-httpd-maintenance@sophos.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nsg-apache-httpd-maintenanc
                   |                            |e@sophos.com

-- 
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


[Bug 62186] ErrorDocument causes POST request getting logged as GET request

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62186

Christophe JAILLET <ch...@wanadoo.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |evanc@nortel.com

--- Comment #4 from Christophe JAILLET <ch...@wanadoo.fr> ---
*** Bug 46969 has been marked as a duplicate of this bug. ***

-- 
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


[Bug 62186] ErrorDocument causes POST request getting logged as GET request

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62186

Christophe JAILLET <ch...@wanadoo.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Christophe JAILLET <ch...@wanadoo.fr> ---
Fixed in 2.4.x in r1830248.
Will be part of 2.4.34

-- 
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