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

Method read_body

gunicorn/asgi/uwsgi.py:132–147  ·  view source on GitHub ↗

Read body chunk asynchronously. Args: size: Maximum bytes to read Returns: bytes: Body data, empty bytes when body is exhausted

(self, size=8192)

Source from the content-addressed store, hash-verified

130 self._body_remaining = content_length
131
132 async def read_body(self, size=8192):
133 """Read body chunk asynchronously.
134
135 Args:
136 size: Maximum bytes to read
137
138 Returns:
139 bytes: Body data, empty bytes when body is exhausted
140 """
141 if self._body_remaining <= 0:
142 return b""
143 to_read = min(size, self._body_remaining)
144 data = await self.unreader.read(to_read)
145 if data:
146 self._body_remaining -= len(data)
147 return data
148
149 async def drain_body(self):
150 """Drain unread body data.

Callers 5

drain_bodyMethod · 0.95
test_read_body_chunksFunction · 0.80
test_drain_bodyFunction · 0.80
test_no_bodyFunction · 0.80

Calls 1

readMethod · 0.45

Tested by 4

test_read_body_chunksFunction · 0.64
test_drain_bodyFunction · 0.64
test_no_bodyFunction · 0.64