Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MaxRedirectsError ¶
type MaxRedirectsError struct {
MaxRedirects int
}
MaxRedirectsError represents an error when the maximum number of redirects is reached.
func (*MaxRedirectsError) Error ¶
func (e *MaxRedirectsError) Error() string
MaxRedirectsError defines an error for when the maximum number of redirects is reached.
type RedirectHandler ¶
type RedirectHandler struct { Logger logger.Logger // Logger instance for logging. MaxRedirects int // Maximum allowed redirects to prevent infinite loops. VisitedURLs map[string]int // Tracks visited URLs to detect loops. VisitedURLsMutex sync.RWMutex // Mutex for safe concurrent access to VisitedURLs. SensitiveHeaders []string // Headers to be removed on cross-domain redirects. PermanentRedirects map[string]string // Cache for permanent redirects PermRedirectsMutex sync.RWMutex // Mutex for safe concurrent access to PermanentRedirects RedirectHistories map[*http.Request][]*url.URL // Map to track redirect history for each request }
RedirectHandler contains configurations for handling HTTP redirects.
func NewRedirectHandler ¶
func NewRedirectHandler(logger logger.Logger, maxRedirects int) *RedirectHandler
NewRedirectHandler creates a new instance of RedirectHandler.
func (*RedirectHandler) AddSensitiveHeader ¶
func (r *RedirectHandler) AddSensitiveHeader(header string)
AddSensitiveHeader allows adding configurable sensitive headers.
func (*RedirectHandler) GetRedirectHistory ¶
func (r *RedirectHandler) GetRedirectHistory(req *http.Request) []*url.URL
GetRedirectHistory returns the redirect history for a given request.
func (*RedirectHandler) WithRedirectHandling ¶
func (r *RedirectHandler) WithRedirectHandling(client *http.Client)
WithRedirectHandling applies the redirect handling policy to an http.Client.
type RedirectLoopError ¶
type RedirectLoopError struct {
URL string
}
RedirectLoopError represents an error when a redirect loop is detected.
func (*RedirectLoopError) Error ¶
func (e *RedirectLoopError) Error() string
RedirectLoopError defines an error for when a redirect loop is detected.