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

Method send

tests/test_asgi_worker.py:505–522  ·  tests/test_asgi_worker.py::_TestProtocol.send
(message)

Source from the content-addressed store, hash-verified

503 return {class="st">"type": class="st">"http.request", class="st">"body": bclass="st">"", class="st">"more_body": False}
504
505 async def send(message):
506 if message[class="st">"type"] == class="st">"http.response.start":
507 status = message[class="st">"status"]
508 headers = message.get(class="st">"headers", [])
509 response = fclass="st">"HTTP/1.1 {status} OK\r\n"
510 for name, value in headers:
511 if isinstance(name, bytes):
512 name = name.decode()
513 if isinstance(value, bytes):
514 value = value.decode()
515 response += fclass="st">"{name}: {value}\r\n"
516 response += class="st">"\r\n"
517 self.transport.write(response.encode())
518 elif message[class="st">"type"] == class="st">"http.response.body":
519 body = message.get(class="st">"body", bclass="st">"")
520 self.transport.write(body)
521 if not message.get(class="st">"more_body", False):
522 self.transport.close()
523
524 await self.app(scope, receive, send)
525

Callers

nothing calls this directly

Calls 5

decodeMethod · 0.80
encodeMethod · 0.80
getMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected