Home / Function/ receive_wrapper() — fastapi Function Reference

receive_wrapper() — fastapi Function Reference

Architecture documentation for the receive_wrapper() function in test_custom_middleware_exception.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  d268a417_9bb1_869f_1b2d_baf49422f22c["receive_wrapper()"]
  74723938_6a55_2853_752f_6576aa5c1d17["ContentSizeLimitMiddleware"]
  d268a417_9bb1_869f_1b2d_baf49422f22c -->|defined in| 74723938_6a55_2853_752f_6576aa5c1d17
  4014ea23_5fbb_eb4b_c698_f3833bb20f2e["__call__()"]
  4014ea23_5fbb_eb4b_c698_f3833bb20f2e -->|calls| d268a417_9bb1_869f_1b2d_baf49422f22c
  style d268a417_9bb1_869f_1b2d_baf49422f22c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_custom_middleware_exception.py lines 24–46

    def receive_wrapper(self, receive):
        received = 0

        async def inner():
            nonlocal received
            message = await receive()
            if message["type"] != "http.request":
                return message  # pragma: no cover

            body_len = len(message.get("body", b""))
            received += body_len
            if received > self.max_content_size:
                raise HTTPException(
                    422,
                    detail={
                        "name": "ContentSizeLimitExceeded",
                        "code": 999,
                        "message": "File limit exceeded",
                    },
                )
            return message

        return inner

Domain

Subdomains

Called By

Frequently Asked Questions

What does receive_wrapper() do?
receive_wrapper() is a function in the fastapi codebase, defined in tests/test_custom_middleware_exception.py.
Where is receive_wrapper() defined?
receive_wrapper() is defined in tests/test_custom_middleware_exception.py at line 24.
What calls receive_wrapper()?
receive_wrapper() is called by 1 function(s): __call__.

Analyze Your Own Codebase

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

Try Supermodel Free