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

Method send

starlette/testclient.py:328–348  ·  starlette/testclient.py::_TestClientTransport.send
(message: Message)

Source from the content-addressed store, hash-verified

326 return {class="st">"type": class="st">"http.request", class="st">"body": body_bytes}
327
328 async def send(message: Message) -> None:
329 nonlocal raw_kwargs, response_started, template, context
330
331 if message[class="st">"type"] == class="st">"http.response.start":
332 assert not response_started, &class="cm">#x27;Received multiple class="st">"http.response.start" messages.'
333 raw_kwargs[class="st">"status_code"] = message[class="st">"status"]
334 raw_kwargs[class="st">"headers"] = [(key.decode(), value.decode()) for key, value in message.get(class="st">"headers", [])]
335 response_started = True
336 elif message[class="st">"type"] == class="st">"http.response.body":
337 assert response_started, &class="cm">#x27;Received class="st">"http.response.body" without class="st">"http.response.start".'
338 assert not response_complete.is_set(), &class="cm">#x27;Received class="st">"http.response.body" after response completed.'
339 body = message.get(class="st">"body", bclass="st">"")
340 more_body = message.get(class="st">"more_body", False)
341 if request.method != class="st">"HEAD":
342 raw_kwargs[class="st">"stream"].write(body)
343 if not more_body:
344 raw_kwargs[class="st">"stream"].seek(0)
345 response_complete.set()
346 elif message[class="st">"type"] == class="st">"http.response.debug":
347 template = message[class="st">"info"][class="st">"template"]
348 context = message[class="st">"info"][class="st">"context"]
349
350 try:
351 with self.portal_factory() as portal:

Callers

nothing calls this directly

Calls 4

decodeMethod · 0.80
seekMethod · 0.80
getMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected