Home / Function/ createOutgoingHttpHeaders() — astro Function Reference

createOutgoingHttpHeaders() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  2626a45e_fc0f_e51d_057b_1acefa71e930["createOutgoingHttpHeaders()"]
  2d6507c6_d73a_ec16_4f36_6a243be56221["createOutgoingHttpHeaders.ts"]
  2626a45e_fc0f_e51d_057b_1acefa71e930 -->|defined in| 2d6507c6_d73a_ec16_4f36_6a243be56221
  style 2626a45e_fc0f_e51d_057b_1acefa71e930 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/app/createOutgoingHttpHeaders.ts lines 10–34

export const createOutgoingHttpHeaders = (
	headers: Headers | undefined | null,
): OutgoingHttpHeaders | undefined => {
	if (!headers) {
		return undefined;
	}

	// at this point, a multi-value'd set-cookie header is invalid (it was concatenated as a single CSV, which is not valid for set-cookie)
	const nodeHeaders: OutgoingHttpHeaders = Object.fromEntries(headers.entries());

	if (Object.keys(nodeHeaders).length === 0) {
		return undefined;
	}

	// if there is > 1 set-cookie header, we have to fix it to be an array of values
	if (headers.has('set-cookie')) {
		const cookieHeaders = headers.getSetCookie();
		if (cookieHeaders.length > 1) {
			// the Headers.entries() API already normalized all header names to lower case so we can safely index this as 'set-cookie'
			nodeHeaders['set-cookie'] = cookieHeaders;
		}
	}

	return nodeHeaders;
};

Domain

Subdomains

Frequently Asked Questions

What does createOutgoingHttpHeaders() do?
createOutgoingHttpHeaders() is a function in the astro codebase, defined in packages/astro/src/core/app/createOutgoingHttpHeaders.ts.
Where is createOutgoingHttpHeaders() defined?
createOutgoingHttpHeaders() is defined in packages/astro/src/core/app/createOutgoingHttpHeaders.ts at line 10.

Analyze Your Own Codebase

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

Try Supermodel Free