feat(server): Allow for custom HEAD method implementations (#1175)
Fixes https://github.com/denoland/fresh/issues/1115 Fixes https://github.com/denoland/fresh/issues/1165 --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
co-authored by
Asher Gomez
parent
366c8afef1
commit
e86a126c0a
@@ -66,6 +66,34 @@ Deno.test("/[name] page prerender", async () => {
|
||||
assertStringIncludes(body, "<div>Hello bar</div>");
|
||||
});
|
||||
|
||||
Deno.test("/intercept - HEAD", async () => {
|
||||
const req = new Request("https://fresh.deno.dev/api/head_override", {
|
||||
method: "HEAD",
|
||||
});
|
||||
const resp = await router(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.NoContent);
|
||||
assertEquals(resp.body, null);
|
||||
assertEquals(
|
||||
resp.headers.get("content-type"),
|
||||
"text/html; charset=utf-8",
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("/intercept - HEAD fallback", async () => {
|
||||
const req = new Request("https://fresh.deno.dev/api/get_only", {
|
||||
method: "HEAD",
|
||||
});
|
||||
const resp = await router(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.body, null);
|
||||
assertEquals(
|
||||
resp.headers.get("content-type"),
|
||||
"application/json; charset=utf-8",
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("/intercept - GET html", async () => {
|
||||
const req = new Request("https://fresh.deno.dev/intercept", {
|
||||
headers: { "accept": "text/html" },
|
||||
|
||||
Reference in New Issue
Block a user