filehttp

package
v0.8.1-alpha.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package filehttp supplies browser response policy for untrusted stored files. Apply it when streaming file bytes, not when serving an application's UI.

Index

Constants

View Source
const SandboxPolicy = "" /* 174-byte string literal not displayed */

SandboxPolicy permits self-contained interactive documents without the application's origin privileges. It permits inline scripts/styles and embedded images, but not external scripts/resources, fetches, forms, workers or frames. Omitting allow-same-origin is essential: adding it restores app-origin access.

Variables

This section is empty.

Functions

func SetHeaders

func SetHeaders(header http.Header, contentType, filename string, download bool)

SetHeaders prepares a stored-file response before any bytes or status are written. download selects attachment disposition; otherwise active documents render inline under SandboxPolicy. Missing/invalid MIME types download as application/octet-stream. Stored metadata and bytes are never modified. Additional CSP policies are retained, so this cannot weaken an outer policy.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL