HTTP Server

Native File Streaming (sendFile)

Enterprise-standard utility for serving physical assets using XHSC Zero-Copy architecture.

Zero-Copy Architecture
Unlike conventional frameworks that buffer file content into the V8 heap, XyPriss streams data directly from the filesystem to the network socket, ensuring minimal memory footprint even for multi-gigabyte files.

Core Capabilities

Native Resolution

Rigorously validated via __sys__.fs, protecting against directory traversal attacks.

MIME Intelligence

Automatic header calculation based on internal MIME_MAP for all major asset classes.

Ranged Delivery

Native support for HTTP Range headers, essential for video seek operations.

Memory Stability

Stable process RSS as data flows through a dedicated native IPC bridge.

Implementation Examples

Standard Asset Delivery

typescript
app.get("/reports/:id", (req, res) => {
    const reportPath = __sys__.path.resolve("./storage/reports/annual.pdf");
    res.sendFile(reportPath); // Content-Type: application/pdf
});

Advanced Download Logic

typescript
res.sendFile("report.pdf", {
    root: "./storage/vault",
    disposition: "attachment",
    headers: { "X-Custom-Header": "Value" },
    maxAge: 3600000 // 1 hour cache
});

Configuration Options

PropertyDescription
rootBase directory for relative path resolution.
maxAgeCache-Control max-age in milliseconds.
headersCustom HTTP headers to serve with the file.
dispositionSets Content-Disposition (inline, attachment).
mimeOverridesMap of extensions to custom MIME types.
Quick Start

Ready to build? Get up and running with XyPriss in minutes.