File size: 488 Bytes
fc93158 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import type { ServerResponse } from "node:http";
export function isReadHttpMethod(method: string | undefined): boolean {
return method === "GET" || method === "HEAD";
}
export function respondPlainText(res: ServerResponse, statusCode: number, body: string): void {
res.statusCode = statusCode;
res.setHeader("Content-Type", "text/plain; charset=utf-8");
res.end(body);
}
export function respondNotFound(res: ServerResponse): void {
respondPlainText(res, 404, "Not Found");
}
|