UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 1.06 kB
import{formatETag as e}from"../../../utils/http/etag.mjs";const t=(t,n)=>{t.header(`Accept-Ranges`,`bytes`),t.header(`X-Content-Type-Options`,`nosniff`),n.contentType?.split(`;`,1)[0]?.trim().toLowerCase()===`image/svg+xml`&&t.header(`Content-Security-Policy`,`sandbox; default-src 'none'; style-src 'unsafe-inline'; img-src data:`),n.key&&t.header(`Content-Disposition`,`inline; filename="${n.key}"`),n.contentLength!==void 0&&t.header(`Content-Length`,String(n.contentLength)),n.contentType&&t.header(`Content-Type`,n.contentType),n.etag&&t.header(`ETag`,e(n.etag))},n=(e,t)=>{t.isPartial&&t.range&&t.totalSize!==void 0?(e.status(206),e.header(`Content-Range`,`bytes ${t.range.start}-${t.range.end}/${t.totalSize}`)):e.header(`Cache-Control`,t.cacheControl??`public, max-age=31536000, immutable`)},r=e=>{if(!e)return;let t=e.match(/bytes=(\d+)-(\d*)/);if(t?.[1])return{start:Number.parseInt(t[1],10),end:t[2]?Number.parseInt(t[2],10):void 0}};export{n as applyRangeHeaders,t as applyStreamingHeaders,r as parseRangeHeader}; //# sourceMappingURL=streaming.mjs.map