INNER CODE UNIT · Python

__call__

MakazhanAlpamys/Soup · src/soup_cli/ui/app.py:64

    async def __call__(self, scope, receive, send) -> None:
        max_body_size = None
        if scope.get("type") == "http" and scope.get("method") == "POST":
            max_body_size = self._limits.get(scope.get("path"))
        if max_body_size is None:
            await self._app(scope, receive, send)
            return

        for key, value in scope.get("headers", ()):
            if key.lower() != b"content-length":
                continue
            try:
                if int(value) > max_body_size:
                    await self._reject(scope, receive, send)
                    return
            except ValueError:
                # Do not trust a malformed header; the receive wrapper below
                # still enforces the actual byte count.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…