Request Metadata and Files¶
Verified status as of March 28, 2026. Runtime note: this page documents current FastFN behavior, including raw-body handling for form and multipart requests.
Complexity¶
Intermediate
Time¶
20-30 minutes
Outcome¶
You understand how headers, cookies, query values, JSON body, forms, and file-upload inputs arrive in FastFN today, and where parsing is explicit.
Validation¶
- Start local runtime:
fastfn dev examples/functions. - Run request metadata check:
- Run JSON body check:
- Run form-urlencoded raw-body check:
Troubleshooting¶
- If headers are missing, inspect casing and reverse-proxy forwarding rules.
- If cookies are empty, confirm the
Cookieheader reaches FastFN. - If JSON parse fails, verify
Content-Typeand payload validity. - For multipart parsing needs, treat current support as raw-body only.
Support matrix¶
| Input type | Current posture | How it arrives |
|---|---|---|
| Headers | Supported | event.headers |
| Cookies | Supported | event.session.cookies |
| Query string | Supported | event.query |
| JSON body | Supported with explicit parsing | event.body raw string |
| Plain text body | Supported | event.body raw string |
application/x-www-form-urlencoded |
Raw-only | event.body raw string |
multipart/form-data |
Raw-only (no first-class parser) | event.body raw string |
| Binary request payloads | Limited | avoid assuming automatic structured parsing |
Headers¶
Python:
def handler(event):
headers = event.get("headers") or {}
return {
"status": 200,
"body": {
"request_id": headers.get("x-request-id"),
"authorized": bool(headers.get("x-api-key")),
},
}
Node:
exports.handler = async (event) => {
const headers = event.headers || {};
return {
status: 200,
body: {
request_id: headers["x-request-id"] || null,
authorized: Boolean(headers["x-api-key"] || null),
},
};
};
Cookies¶
FastFN exposes parsed cookies under event.session.cookies.
Python:
def handler(event):
session = event.get("session") or {}
cookies = session.get("cookies") or {}
return {"status": 200, "body": {"theme": cookies.get("theme", "light")}}
JSON and plain-text bodies¶
Body is raw text. Parse explicitly.
Python:
import json
def handler(event):
payload = json.loads(event.get("body") or "{}")
return {
"status": 200,
"body": {
"title": payload.get("title"),
"priority": int(payload.get("priority", 1)),
},
}
Node:
exports.handler = async (event) => {
const payload = JSON.parse(event.body || "{}");
return {
status: 200,
body: {
title: payload.title || null,
priority: Number(payload.priority || 1),
},
};
};
Forms and multipart¶
application/x-www-form-urlencoded: available as raw string inevent.body.multipart/form-data: currently raw-only in gateway contract; no built-in field/file abstraction.
Practical recommendation: 1. Prefer JSON for API contracts. 2. Keep multipart parsing explicit in runtime code only when you fully control format. 3. For heavy upload workflows, use specialized upstream components.
Limits that matter¶
- Request size is constrained by
max_body_bytes. - Per-function policy still applies before handler execution.
- Response metadata (cookies/headers) remains controlled by response envelope fields.
Related links¶
Last reviewed:
March 28, 2026
·
Docs on fastfn.dev