oak icon indicating copy to clipboard operation
oak copied to clipboard

etag.calculate always returns weak

Open CanRau opened this issue 3 years ago • 2 comments

I'm passing in a string, which should, according to the readme, calculate a strong etag and setting weak to false

await etag.calculate(myString, { weak: false })

Result is still a weak ETag prefixed with W/, what am I doing wrong? Feels a little like the nullish coalescing isn't doing its job 🤔 https://github.com/oakserver/oak/blob/9ce772628961a8a1edec92b3c5d62d09f5d7c7f4/etag.ts#L110

CanRau avatar Jun 22 '22 21:06 CanRau

@CanRau I don't think it's that. The comments say that the "weak" options overrides the default behavior. Look a couple lines down. https://github.com/oakserver/oak/blob/9ce772628961a8a1edec92b3c5d62d09f5d7c7f4/etag.ts#L115

binyamin avatar Jul 20 '22 00:07 binyamin

I had the same problem as you when I wrote my http sever.

I print etag.calculate return value. It indeed is strong etag. But I still get weak etag in browser response.

Until I saw this. https://deno.land/manual/runtime/http_server_apis#what-happens-to-an-etag-header

I suggest you use weak etag or skip deno automatic compression.

skyyangyun avatar Jul 21 '22 09:07 skyyangyun

Thanks for the insides, and yeah I probably misinterpreted the code there, also thanks for the links 🙏

Closing as everything seems to be fine and I'm currently not working with Oak so 😥😅

CanRau avatar Aug 11 '22 23:08 CanRau