#2 fix(server): respond to HEAD / so health checks return 200

Scalone
jschoubben scala 1 commity/ów z fix/head-method do main 1 miesiąc temu
jschoubben skomentował(-a) 1 miesiąc temu

Problem

curl -sSI https://txt.zurag.be sends a HEAD request. The server only handled GET and POST, so HEAD fell through to the catch-all 404 handler — blocking the acceptance criterion even though the site was fully functional for browsers and game play.

Change

Single-line fix in the GET / handler:

-  if (req.method === "GET" && url === "/") {
+  if ((req.method === "GET" || req.method === "HEAD") && url === "/") {
     setCookie(res, id);
     res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
-    res.end(renderPage(session, "", null));
+    res.end(req.method === "HEAD" ? "" : renderPage(session, "", null));

HEAD gets the same 200 + Content-Type headers as GET; body is empty (correct per RFC 7231).

Test plan

After merge + pipeline redeploy:

  • curl -sSI https://txt.zurag.beHTTP/2 200
  • curl -sS https://txt.zurag.be → game HTML (unchanged)
  • POST /guess still works as before

Task: dd07738f-6e58-4702-86c3-c43b85f236d2

## Problem `curl -sSI https://txt.zurag.be` sends a HEAD request. The server only handled `GET` and `POST`, so HEAD fell through to the catch-all `404` handler — blocking the acceptance criterion even though the site was fully functional for browsers and game play. ## Change Single-line fix in the `GET /` handler: ```diff - if (req.method === "GET" && url === "/") { + if ((req.method === "GET" || req.method === "HEAD") && url === "/") { setCookie(res, id); res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }); - res.end(renderPage(session, "", null)); + res.end(req.method === "HEAD" ? "" : renderPage(session, "", null)); ``` HEAD gets the same 200 + `Content-Type` headers as GET; body is empty (correct per RFC 7231). ## Test plan After merge + pipeline redeploy: - `curl -sSI https://txt.zurag.be` → `HTTP/2 200` - `curl -sS https://txt.zurag.be` → game HTML (unchanged) - POST /guess still works as before Task: dd07738f-6e58-4702-86c3-c43b85f236d2
jschoubben zamknął(-ęła) 1 miesiąc temu
Pull Request został scalony jako 0139527147.
Zaloguj się, aby dołączyć do tej rozmowy.
Brak etykiety
Brak kamienia milowego
Brak przypisanych
Uczestnicy 1
Termin realizacji

Brak ustawionego terminu realizacji.

Zależności

Ten Pull Request nie zawiera w tej chwili żadnych zależności.

Ładowanie…
Anuluj
Zapisz
Nie ma jeszcze treści.