MCPcopy
hub / github.com/encode/starlette / stream

Method stream

starlette/requests.py:234–252  ·  starlette/requests.py::Request.stream
(self)

Source from the content-addressed store, hash-verified

232 return self._receive
233
234 async def stream(self) -> AsyncGenerator[bytes, None]:
235 if hasattr(self, class="st">"_body"):
236 yield self._body
237 yield bclass="st">""
238 return
239 if self._stream_consumed:
240 raise RuntimeError(class="st">"Stream consumed")
241 while not self._stream_consumed:
242 message = await self._receive()
243 if message[class="st">"type"] == class="st">"http.request":
244 body = message.get(class="st">"body", bclass="st">"")
245 if not message.get(class="st">"more_body", False):
246 self._stream_consumed = True
247 if body:
248 yield body
249 elif message[class="st">"type"] == class="st">"http.disconnect": class="cm"># pragma: no branch
250 self._is_disconnected = True
251 raise ClientDisconnect()
252 yield bclass="st">""
253
254 async def body(self) -> bytes:
255 if not hasattr(self, class="st">"_body"):

Callers 9

bodyMethod · 0.95
_get_formMethod · 0.95
appFunction · 0.95
endpointFunction · 0.95
__init__Method · 0.80
wrapped_receiveMethod · 0.80
homepageFunction · 0.80
dispatchMethod · 0.80

Calls 2

ClientDisconnectClass · 0.85
getMethod · 0.45

Tested by 5

appFunction · 0.76
endpointFunction · 0.76
homepageFunction · 0.64
dispatchMethod · 0.64