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

已合併
jschoubben 1 月之前 將 1 次代碼提交從 fix/head-method合併至 main

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
The pull request has been merged as 0139527147.
登入 才能加入這對話。
未選擇標籤
未選擇里程碑
No Assignees
1 參與者
截止日期

未設定截止日期。

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
取消
儲存
尚未有任何內容