Home / Function/ toHeaders() — astro Function Reference

toHeaders() — astro Function Reference

Architecture documentation for the toHeaders() function in sirv.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  fcc6f6e1_b00f_7d7d_a9ee_5a33a05d47bf["toHeaders()"]
  afcb3082_013d_93cb_836e_f55956dc999b["sirv.ts"]
  fcc6f6e1_b00f_7d7d_a9ee_5a33a05d47bf -->|defined in| afcb3082_013d_93cb_836e_f55956dc999b
  2025ed08_2d85_c00f_dfd5_7481eefc2824["viaLocal()"]
  2025ed08_2d85_c00f_dfd5_7481eefc2824 -->|calls| fcc6f6e1_b00f_7d7d_a9ee_5a33a05d47bf
  style fcc6f6e1_b00f_7d7d_a9ee_5a33a05d47bf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/partytown/src/sirv.ts lines 137–153

function toHeaders(name, stats, isEtag) {
	let enc = ENCODING[name.slice(-3)];

	let ctype = lookup(name.slice(0, enc && -3)) || '';
	if (ctype === 'text/html') ctype += ';charset=utf-8';

	let headers = {
		'Content-Length': stats.size,
		'Content-Type': ctype,
		'Last-Modified': stats.mtime.toUTCString(),
	};

	if (enc) headers['Content-Encoding'] = enc;
	if (isEtag) headers['ETag'] = `W/"${stats.size}-${stats.mtime.getTime()}"`;

	return headers;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does toHeaders() do?
toHeaders() is a function in the astro codebase, defined in packages/integrations/partytown/src/sirv.ts.
Where is toHeaders() defined?
toHeaders() is defined in packages/integrations/partytown/src/sirv.ts at line 137.
What calls toHeaders()?
toHeaders() is called by 1 function(s): viaLocal.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free