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

Empty URI in logs when using fcgi protocol #14312

Closed
2 of 6 tasks
WKBae opened this issue Jan 12, 2021 · 1 comment · Fixed by #14314
Closed
2 of 6 tasks

Empty URI in logs when using fcgi protocol #14312

WKBae opened this issue Jan 12, 2021 · 1 comment · Fixed by #14314
Labels

Comments

@WKBae
Copy link
Contributor

WKBae commented Jan 12, 2021

  • Gitea version (or commit ref): 1.13.1
  • Git version: 2.26.2
  • Operating system: Official Docker image; gitea/gitea:1.13.1
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:
[Macaron] 2021-01-12 10:00:58: Started GET  for xxx.xxx.xxx.xxx
[Macaron] [Static] Serving /serviceworker.js
[Macaron] 2021-01-12 10:00:58: Completed GET  304 Not Modified in 479.996µs
[Macaron] 2021-01-12 10:00:58: Completed GET  304 Not Modified in 479.996µs
[Macaron] 2021-01-12 10:00:58: Started GET  for xxx.xxx.xxx.xxx
[Macaron] 2021-01-12 10:00:58: Started GET  for xxx.xxx.xxx.xxx
[Macaron] 2021-01-12 10:00:58: Completed GET  200 OK in 3.775066ms
[Macaron] 2021-01-12 10:00:58: Completed GET  200 OK in 3.775066ms

Description

When using PROTOCOL = fcgi, request paths(http.Request.RequestURI) are not shown in the logs.

Go's net/http/cgi.RequestFromMap(), which net/http/fcgi uses, does not populate RequestURI(but does URL). As RequestURI is documented "Usually the URL field should be used instead", req.URL.RequestURI() may be a simple and recommended alternative.

_ = log.GetLogger("router").Log(0, level, "Started %s %s for %s", log.ColoredMethod(req.Method), req.RequestURI, req.RemoteAddr)

_ = log.GetLogger("router").Log(0, level, "Completed %s %s %v %s in %v", log.ColoredMethod(req.Method), req.RequestURI, log.ColoredStatus(status), log.ColoredStatus(status, http.StatusText(status)), log.ColoredTime(time.Since(start)))

Screenshots

None

@WKBae
Copy link
Contributor Author

WKBae commented Jan 12, 2021

Found #9473 this previous PR while investigating.

@lunny lunny added the type/bug label Jan 13, 2021
a1012112796 added a commit to a1012112796/gitea that referenced this issue Jan 14, 2021
* master:
  Use Request.URL.RequestURI() for fcgi (go-gitea#14312) (go-gitea#14314)
  Update Link
  [skip ci] Updated translations via Crowdin
  Kd/add bountysource (go-gitea#14323)
lunny pushed a commit that referenced this issue Jan 15, 2021
Co-authored-by: Lauris BH <lauris@nix.lv>
@go-gitea go-gitea locked and limited conversation to collaborators Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants