Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions website/tests/test_version_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ def test_payload_from_settings_and_no_store_header(self):
# Always present, even without a build-info file.
self.assertIn("git_sha", data)
self.assertIn("built_at", data)
# The live WSGI server's self-reported SERVER_SOFTWARE (#1034); always
# present so we can confirm gunicorn vs. the dev runserver in deploys.
self.assertIn("server", data)

def test_server_reflects_wsgi_server_software(self):
# The view reports request.META["SERVER_SOFTWARE"] verbatim; on the real
# servers that's "gunicorn/<ver>" after #1034. Simulate it here.
data = json.loads(
self.client.get("/version/", SERVER_SOFTWARE="gunicorn/23.0.0").content
)
self.assertEqual(data["server"], "gunicorn/23.0.0")

def test_build_info_missing_falls_back_to_unknown(self):
with override_settings():
Expand Down
11 changes: 10 additions & 1 deletion website/views/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@
"description": "Fix the project listing page ...",
"environment": "PROD",
"git_sha": "02909b0",
"built_at": "2026-06-21T18:30:00-07:00"
"built_at": "2026-06-21T18:30:00-07:00",
"server": "gunicorn/23.0.0"
}

The ``server`` field is the WSGI server's self-reported ``SERVER_SOFTWARE``
(``gunicorn/<ver>`` vs. Django's ``WSGIServer/<ver> CPython/<ver>``), read off
the live request -- it's the ground-truth answer to *"is this actually running
Gunicorn?"* after the #1034 swap, not an inference from env vars or git_sha.
"""

import json
Expand Down Expand Up @@ -83,6 +89,9 @@ def version(request, format=None):
"environment": settings.DJANGO_ENV or "unknown",
"git_sha": build_info["git_sha"],
"built_at": build_info["built_at"],
# WSGI server handling this request: "gunicorn/<ver>" under #1034,
# "WSGIServer/<ver> CPython/<ver>" if the dev runserver is somehow live.
"server": request.META.get("SERVER_SOFTWARE", "unknown"),
}
response = JsonResponse(payload)
response["Cache-Control"] = "no-store"
Expand Down
Loading