Home / Function/ parseRequestBody() — astro Function Reference

parseRequestBody() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  d2a22336_a5ee_9bc2_8056_2770db2de333["parseRequestBody()"]
  12df90c3_b0fe_d858_b821_5011b6067fdb["server.ts"]
  d2a22336_a5ee_9bc2_8056_2770db2de333 -->|defined in| 12df90c3_b0fe_d858_b821_5011b6067fdb
  87610e32_7608_ae90_0908_65538303d4a6["getActionContext()"]
  87610e32_7608_ae90_0908_65538303d4a6 -->|calls| d2a22336_a5ee_9bc2_8056_2770db2de333
  d1eef9a9_8a0f_eb02_6578_097c5ac98e0f["hasContentType()"]
  d2a22336_a5ee_9bc2_8056_2770db2de333 -->|calls| d1eef9a9_8a0f_eb02_6578_097c5ac98e0f
  style d2a22336_a5ee_9bc2_8056_2770db2de333 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/actions/runtime/server.ts lines 253–265

async function parseRequestBody(request: Request) {
	const contentType = request.headers.get('content-type');
	const contentLength = request.headers.get('Content-Length');

	if (!contentType) return undefined;
	if (hasContentType(contentType, formContentTypes)) {
		return await request.clone().formData();
	}
	if (hasContentType(contentType, ['application/json'])) {
		return contentLength === '0' ? undefined : await request.clone().json();
	}
	throw new TypeError('Unsupported content type');
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does parseRequestBody() do?
parseRequestBody() is a function in the astro codebase, defined in packages/astro/src/actions/runtime/server.ts.
Where is parseRequestBody() defined?
parseRequestBody() is defined in packages/astro/src/actions/runtime/server.ts at line 253.
What does parseRequestBody() call?
parseRequestBody() calls 1 function(s): hasContentType.
What calls parseRequestBody()?
parseRequestBody() is called by 1 function(s): getActionContext.

Analyze Your Own Codebase

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

Try Supermodel Free