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

AccessLog should use raw_path #75

Closed
synodriver opened this issue Sep 3, 2022 · 2 comments
Closed

AccessLog should use raw_path #75

synodriver opened this issue Sep 3, 2022 · 2 comments

Comments

@synodriver
Copy link
Contributor

Some asgi frameworks, for example, starlette, modifies scope["path"] during execution, which confuses the log output because hypercorn uses that to record the path.

@synodriver
Copy link
Contributor Author

synodriver commented Sep 3, 2022

Step to reproduce

  • The code
from fastapi import FastAPI

app = FastAPI(title="CGI Server")

app.mount("/cgi-bin", Someapp)  # type: ignore

if __name__ == "__main__":
    import asyncio

    from hypercorn.asyncio import serve
    from hypercorn.config import Config

    conf = Config.from_mapping(accesslog="-", bind="0.0.0.0:8000", loglevel="DEBUG")
    asyncio.run(serve(app, conf))  # type: ignore
  • Then
curl http://127.0.0.1:8000/cgi-bin/env.cgi

expected

[2022-09-03 23:10:16 +0800] [28820] [INFO] 127.0.0.1:59981 - - [03/Sep/2022:23:10:16 +0800] "GET /cgi-bin/env.cgi 1.1" 200 - "-" "Apache-HttpClient/4.5.13 (Java/17.0.3)"

got

[2022-09-03 23:12:08 +0800] [28820] [INFO] 127.0.0.1:60235 - - [03/Sep/2022:23:12:08 +0800] "GET /env.cgi 1.1" 200 - "-" "Apache-HttpClient/4.5.13 (Java/17.0.3)"

@pgjones
Copy link
Owner

pgjones commented May 26, 2024

Issue was with Starlette

@pgjones pgjones closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2024
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

2 participants