On this page
HTTP response types including JSON, text, HTML, bytes, and streaming responses, plus cookie helpers and low-level ASGI send functions.
#src.fastware.responses
#src.fastware.responses
HTTP response types including JSON, text, HTML, bytes, and streaming responses, plus cookie helpers and low-level ASGI send functions.
#set_cookie
def set_cookie(name: str, value: str, *, httponly: bool=False, samesite: str='lax', max_age: int | None=None, path: str='/', secure: bool=False) -> strBuild a Set-Cookie header string.
#delete_cookie
def delete_cookie(name: str, *, path: str='/') -> strBuild a Set-Cookie header string that clears the cookie.
#HTTPError
Raise from handlers to return a specific HTTP error status.
#JSONResponse
JSON response with optional status code, headers, and cookies.
#TextResponse
Plain text or CSS response.
headers (optional) is merged with the framework's default response headers; values must already be plain strings.
#HTMLResponse
HTML response.
#BytesResponse
Raw bytes response with an explicit content type.
#StreamResponse
Streaming response (for SSE).
#FileResponse
Serve a file from disk with MIME detection and Content-Length.
#_send_response
async def _send_response(send: Callable, status: int, body: bytes, content_type: str, extra_headers: dict[str, str] | None=None, cookies: list[str] | None=None) -> NoneSend a complete HTTP response (headers + body).
#send_error
async def send_error(send: Callable, status: int, detail: str) -> NoneSend a complete JSON error response via raw ASGI send calls.
Intended for use by middleware that needs to short-circuit with an error without constructing response objects.