{"record":{"id":"acfdc6887483b66c","repo":"denoland/deno","slug":"response-status-must-not-be-206","errorCode":null,"errorMessage":"Response status must not be 206","messagePattern":"Response status must not be 206","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/cache/01_cache.js","lineNumber":160,"sourceCode":"    } else {\n      // Step 3.\n      innerRequest = toInnerRequest(new Request(request));\n    }\n    // Step 4.\n    const reqUrl = new URL(innerRequest.url());\n    if (reqUrl.protocol !== \"http:\" && reqUrl.protocol !== \"https:\") {\n      throw new TypeError(\n        `Request url protocol must be 'http:' or 'https:': received '${reqUrl.protocol}'`,\n      );\n    }\n    if (innerRequest.method !== \"GET\") {\n      throw new TypeError(\"Request method must be GET\");\n    }\n    // Step 5.\n    const innerResponse = toInnerResponse(response);\n    // Step 6.\n    if (innerResponse.status === 206) {\n      throw new TypeError(\"Response status must not be 206\");\n    }\n    // Step 7.\n    const varyHeader = getHeader(innerResponse.headerList, \"vary\");\n    if (varyHeader) {\n      const fieldValues = StringPrototypeSplit(varyHeader, \",\");\n      for (let i = 0; i < fieldValues.length; ++i) {\n        const field = fieldValues[i];\n        if (StringPrototypeTrim(field) === \"*\") {\n          throw new TypeError(\"Vary header must not contain '*'\");\n        }\n      }\n    }\n\n    // Step 8.\n    if (innerResponse.body !== null && innerResponse.body.unusable()) {\n      throw new TypeError(\"Response body is already used\");\n    }\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/cache/01_cache.js#L142-L178","documentation":"Cache.put(request, response) rejects responses with status 206 Partial Content (spec step 6). A 206 response is the result of a Range request and represents only a fragment of the resource, so the Cache API refuses to store it.","triggerScenarios":"`cache.put(req, res)` where res.status === 206, typically because the fetch sent a Range header and the origin answered with partial content.","commonSituations":"Media streaming or resumable-download code that fetches ranges and then tries to cache the fragment; proxies that forward Range requests.","solutions":["Fetch the full resource (omit the Range header) before caching","Skip caching when `response.status === 206`","If the body is actually complete, rebuild a 200 Response around it before caching"],"exampleFix":"// before\nconst res = await fetch(url, { headers: { Range: \"bytes=0-1023\" } });\nawait cache.put(req, res); // 206 -> throws\n\n// after\nconst res = await fetch(url); // full body\nif (res.status === 200) await cache.put(req, res);","handlingStrategy":"validation","validationCode":"if (response.status === 206) {\n  // partial content: fetch the full resource instead of caching\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not send Range headers for resources you intend to cache","Gate caching on response.status === 200","Rebuild a complete 200 Response around a known-complete body before caching"],"tags":["cache-api","http-status","range-requests"],"backgroundTag":"partial-content-not-cacheable","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}