Skip to content

Commit cd20e3d

Browse files
authored
Update docs/web_advanced.rst
1 parent e990fba commit cd20e3d

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

docs/web_advanced.rst

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -720,22 +720,6 @@ In contrast, when accessing the stream directly (not recommended in middleware):
720720
# body = await request.text() # This would read from internal cache if available
721721
return web.Response(text=f"Received: {data}")
722722

723-
When working with raw stream data that needs to be shared between middleware and handlers::
724-
725-
async def stream_parsing_middleware(
726-
request: web.Request,
727-
handler: Callable[[web.Request], Awaitable[web.StreamResponse]]
728-
) -> web.StreamResponse:
729-
# Read stream once and store the data
730-
raw_data = await request.content.read()
731-
request['raw_body'] = raw_data
732-
return await handler(request)
733-
734-
async def handler(request: web.Request) -> web.Response:
735-
# Access the stored data instead of reading the stream again
736-
raw_data = request.get('raw_body', b'')
737-
return web.Response(body=raw_data)
738-
739723
Example
740724
^^^^^^^
741725

0 commit comments

Comments
 (0)