class Halite::Redirector

Defined in:

halite/redirector.cr

Constant Summary

REDIRECT_CODES = [300, 301, 302, 303, 307, 308]

HTTP status codes which indicate redirects

SEE_OTHER_ALLOWED_VERBS = ["GET", "HEAD"] of ::String

Verbs which will remain unchanged upon See Other response.

STRICT_SENSITIVE_CODES = [300, 301, 302]

Codes which which should raise StateError in strict mode if original request was any of {UNSAFE_VERBS}

UNSAFE_VERBS = ["PUT", "DELETE", "POST"] of ::String

Insecure http verbs, which should trigger StateError in strict mode upon {STRICT_SENSITIVE_CODES}

Constructors

Instance Method Summary

Constructor Detail

def self.new(request : Halite::Request, response : Halite::Response, options : Halite::Options) #

def self.new(request : Halite::Request, response : Halite::Response, max_hops = 5, strict = true) #

Instance a new Redirector


Instance Method Detail

def avaiable? #

Return true if it should redirect, else false


def each_redirect(&block : Halite::Request -> Halite::Response) #

Loop each redirect request with block call


def endless_loop? #

Check if we got into an endless loop


def max_hops : Int32 #

def perform(&block : Halite::Request -> Halite::Response) : Halite::Response #

Follows redirects until non-redirect response found


def strict : Bool #