ushka.http.response
This module defines the Response class for handling HTTP responses.
The Response class ensures correct formatting for ASGI compatibility and
automatically handles Cookie and Session persistence if a Request object is provided.
class Response
Represents an outgoing HTTP response.
__init__(self, body: str | int | Dict | List | bytes = '', status_code: int = 200, headers: Dict[str, str] | None = None, media_type: str | None = None, request: Optional[Request] = None) -> None
Initializes a new Response object.
Parameters
body | str, int, dict, list, or bytes | The content for the response body. Can be a string, integer, dictionary (will be JSON-encoded), list (will be JSON-encoded), or raw bytes. Defaults to an empty string. |
status_code | int | The HTTP status code for the response. Defaults to 200. |
headers | Dict[str, str] | A dictionary of custom HTTP headers to include in the response.
Defaults to |
media_type | str | The explicit MIME type for the response (e.g., "text/html", "application/json").
If |
request | Request | An optional reference to the incoming |