Skip to main content

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

AttributeTypeDescription
allowed_schemeslist = ["http", "https", "ftp"]A list of permitted URL protocols used to validate the redirect target and prevent unsafe redirects.
urlstringThe 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

NameTypeDescription
redirect_tostrThe URL to which the response should redirect.
preserve_requestbool = FalseWhether to use a status code that preserves the request method.
*argsanyPositional arguments passed to the parent HttpResponse class.
max_lengthint = MAX_URL_REDIRECT_LENGTHThe maximum allowed length for the redirect URL.
**kwargsanyKeyword arguments passed to the parent HttpResponse class.