diff --git a/in_memory_test.ts b/in_memory_test.ts index 9ada8f5..11bee30 100644 --- a/in_memory_test.ts +++ b/in_memory_test.ts @@ -21,7 +21,7 @@ Deno.test("[in memory] cache, retrieve, delete", async () => { originalResp.headers.get("server"), cachedResp.headers.get("server"), ); - assertEquals(await cachedResp.text(), "Hello World"); + assertEquals(await originalResp.text(), await cachedResp.text()); await cache.delete("https://deno.land"); diff --git a/mod.ts b/mod.ts index 9ede274..58de105 100644 --- a/mod.ts +++ b/mod.ts @@ -51,9 +51,8 @@ export class Cache { } async put(request: RequestInfo, response: Response): Promise { - const req = request instanceof Request - ? request.clone() - : new Request(request); + const req = request instanceof Request ? request : new Request(request); + response = response.clone(); const status = response.status; const headers = Object.fromEntries(response.headers.entries()); diff --git a/redis_test.ts b/redis_test.ts index 46383ff..3a53d7d 100644 --- a/redis_test.ts +++ b/redis_test.ts @@ -21,7 +21,7 @@ Deno.test("[redis] cache, retrieve, delete", async () => { originalResp.headers.get("server"), cachedResp.headers.get("server"), ); - assertEquals(await cachedResp.text(), "Hello World"); + assertEquals(await originalResp.text(), await cachedResp.text()); await cache.delete("https://deno.land");