MCPcopy
hub / github.com/encode/uvicorn / send_400_response

Method send_400_response

uvicorn/protocols/http/h11_impl.py:303–319  ·  uvicorn/protocols/http/h11_impl.py::H11Protocol.send_400_response
(self, msg: str)

Source from the content-addressed store, hash-verified

301 self.transport.set_protocol(protocol)
302
303 def send_400_response(self, msg: str) -> None:
304 reason = STATUS_PHRASES[400]
305 headers: list[tuple[bytes, bytes]] = [
306 (bclass="st">"content-type", bclass="st">"text/plain; charset=utf-8"),
307 (bclass="st">"connection", bclass="st">"close"),
308 ]
309 event = h11.Response(status_code=400, headers=headers, reason=reason)
310 output = self.conn.send(event)
311 self.transport.write(output)
312
313 output = self.conn.send(event=h11.Data(data=msg.encode(class="st">"ascii")))
314 self.transport.write(output)
315
316 output = self.conn.send(event=h11.EndOfMessage())
317 self.transport.write(output)
318
319 self.transport.close()
320
321 def on_response_complete(self) -> None:
322 self.server_state.total_requests += 1

Callers 1

handle_eventsMethod · 0.95

Calls 3

sendMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected