HttpResponseRedirectBase
This class serves as a base for HTTP redirect responses, handling the validation and setting of the redirect URL. It ensures that redirect locations conform to allowed URI schemes and do not exceed a specified maximum length. The class also supports preserving the original request method during the redirect process by adjusting the HTTP status code.
Attributes
| Attribute | Type | Description |
|---|---|---|
| allowed_schemes | list = ["http", "https", "ftp"] | A list of permitted URL protocols used to validate the redirect target and prevent unsafe redirects. |
| url | string | The destination URI for the redirect, retrieved from the Location header of the response. |
Constructor
Signature
def HttpResponseRedirectBase(
redirect_to: str,
preserve_request: bool = False,
*args: any,
max_length: int = MAX_URL_REDIRECT_LENGTH,
**kwargs: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| redirect_to | str | The URL to which the response should redirect. |
| preserve_request | bool = False | Whether to use a status code that preserves the request method. |
| *args | any | Positional arguments passed to the parent HttpResponse class. |
| max_length | int = MAX_URL_REDIRECT_LENGTH | The maximum allowed length for the redirect URL. |
| **kwargs | any | Keyword arguments passed to the parent HttpResponse class. |