MCPcopy
hub / github.com/encode/starlette / app_with_headers

Function app_with_headers

tests/test_formparsers.py:78–96  ·  view source on GitHub ↗
(scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

76
77
78async def app_with_headers(scope: Scope, receive: Receive, send: Send) -> None:
79 request = Request(scope, receive)
80 data = await request.form()
81 output: dict[str, Any] = {}
82 for key, value in data.items():
83 if isinstance(value, UploadFile):
84 content = await value.read()
85 output[key] = {
86 "filename": value.filename,
87 "size": value.size,
88 "content": content.decode(),
89 "content_type": value.content_type,
90 "headers": list(value.headers.items()),
91 }
92 else:
93 output[key] = value
94 await request.close()
95 response = JSONResponse(output)
96 await response(scope, receive, send)
97
98
99async def app_read_body(scope: Scope, receive: Receive, send: Send) -> None:

Callers

nothing calls this directly

Calls 7

formMethod · 0.95
closeMethod · 0.95
RequestClass · 0.90
JSONResponseClass · 0.90
readMethod · 0.80
decodeMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected