diff --git a/lib/http.mjs b/lib/http.mjs index c5a7778..5d1bf54 100644 --- a/lib/http.mjs +++ b/lib/http.mjs @@ -43,6 +43,7 @@ const httpOpts = new Map([ [403, { status: 403, statusText: 'Forbidden' }], [404, { status: 404, statusText: 'Not Found' }], [405, { status: 405, statusText: 'Method Not Allowed', headers: HEADERS_ALLOW }], + [412, { status: 412, statusText: 'Precondition Failed' }], [416, { status: 416, statusText: 'Range Not Satisfiable' }], [422, { status: 422, statusText: 'Unprocessable Content' }], [500, { status: 500, statusText: 'Internal Server Error' }], diff --git a/lib/methods.mjs b/lib/methods.mjs index 724fa6d..21f9e15 100644 --- a/lib/methods.mjs +++ b/lib/methods.mjs @@ -43,6 +43,17 @@ const GET = async (url, { headers, integrity, signal }) => { await statsAsOptions(stats, { status: 304 }) ); + if (headers.has('If-Match') && + !headers.get('If-Match') + .split(',') + .map($ => $.trim()) + .includes(computeWeakETag(stats)) + ) + return new Response( + null, + await statsAsOptions(stats, { status: 412 }) + ); + const ranges = getRanges(headers); return ranges.length