feat: add etag to static files (#95)

This commit is contained in:
Leo Kettmeir
2022-03-03 14:18:29 +01:00
committed by GitHub
parent 38ac19a042
commit d441bf2489
3 changed files with 48 additions and 9 deletions
+1
View File
@@ -0,0 +1 @@
bar
+17
View File
@@ -182,3 +182,20 @@ Deno.test("/foo/:path*", async () => {
const body = await resp.text();
assert(body.includes("bar/baz"));
});
Deno.test("static file", async () => {
const resp = await router(new Request("https://fresh.deno.dev/foo.txt"));
assertEquals(resp.status, 200);
const body = await resp.text();
assert(body.startsWith("bar"));
assert(resp.headers.get("etag"));
const resp2 = await router(
new Request("https://fresh.deno.dev/foo.txt", {
headers: {
"if-none-match": resp.headers.get("etag")!,
},
}),
);
assertEquals(resp2.status, 304);
});