Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InternalRedirect access logging -> log original request instead of redirected #1994

Open
easy-easy opened this issue Apr 24, 2023 · 0 comments

Comments

@easy-easy
Copy link

easy-easy commented Apr 24, 2023

Hello,

this is a bug/feature request (not sure what exactly matches).

I'm using a default implementation for an online shop using regex for "beautiful urls".

For reroute the request I use the InternalRedirect Exception, which works fine.
But at the access log there appears the redirected entry instead of the original one.
How can I log the original entry instead?

import cherrypy

class Root:
    @cherrypy.expose
    def default(self, *args, **kwargs):
        print('default')
        raise cherrypy.InternalRedirect('/destination/?p='+'/'.join(args))

    @cherrypy.expose
    def destination(self, p: str = None):
        print(f'destination: {p}')

cherrypy.quickstart(Root())

If I call this with http://localhost/testurl.html the logentry created logs the url: /destination/?p=testurl.html

The output is:

default
destination: testurl.html

The accesslog entry:

127.0.0.1 - - [24/Apr/2023:10:21:29] "GET /destination/p=testurl.html HTTP/1.1" 200 - "" "Wget/1.21.3"

I need to log the original url instead in the access log. How can I to this?

Regards,
easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant