Skip to content

Empty URI in logs when using fcgi protocol #14312

Closed
@WKBae

Description

@WKBae
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions