MCPcopy
hub / github.com/benoitc/gunicorn / echo

Function echo

tests/docker/asgi_framework_compat/frameworks/litestar_app/app.py:84–100  ·  view source on GitHub ↗

Echo request body back.

(request: Request)

Source from the content-addressed store, hash-verified

82
83@post("/echo")
84async def echo(request: Request) -> Response:
85 """Echo request body back."""
86 # Read body using the receive callable to avoid Litestar's internal caching
87 body_parts = []
88 while True:
89 message = await request.receive()
90 body = message.get("body", b"")
91 if body:
92 body_parts.append(body)
93 if not message.get("more_body", False):
94 break
95 body = b"".join(body_parts)
96 # Access headers directly from scope to avoid Litestar's caching
97 scope_headers = {name.decode("latin-1"): value.decode("latin-1")
98 for name, value in request.scope.get("headers", [])}
99 content_type = scope_headers.get("content-type", "application/octet-stream")
100 return Response(content=body, media_type=content_type, status_code=200)
101
102
103@get("/headers")

Callers

nothing calls this directly

Calls 4

ResponseClass · 0.85
decodeMethod · 0.80
receiveMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected