(self, payload: object)
| 63 | self.send_error(HTTPStatus.NOT_FOUND, "Run not found") |
| 64 | |
| 65 | def send_json(self, payload: object) -> None: |
| 66 | body = json.dumps(payload).encode("utf-8") |
| 67 | etag = payload_etag(payload) |
| 68 | if self.headers.get("If-None-Match") == etag: |
| 69 | self.send_response(HTTPStatus.NOT_MODIFIED) |
| 70 | self.send_header("ETag", etag) |
| 71 | self.end_headers() |
| 72 | return |
| 73 | self.send_response(HTTPStatus.OK) |
| 74 | self.send_header("Content-Type", "application/json; charset=utf-8") |
| 75 | self.send_header("Content-Length", str(len(body))) |
| 76 | self.send_header("Cache-Control", "no-store") |
| 77 | self.send_header("ETag", etag) |
| 78 | self.end_headers() |
| 79 | try: |
| 80 | self.wfile.write(body) |
| 81 | except (BrokenPipeError, ConnectionResetError): |
| 82 | return |
| 83 | |
| 84 | def serve_file(self, path: Path) -> None: |
| 85 | if not path.exists() or not path.is_file(): |
no test coverage detected