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) #

[View source]
def self.new(request : Halite::Request, response : Halite::Response, max_hops : Int32 = 5, strict : Bool = true) #

Instance a new Redirector


[View source]

Instance Method Detail

def avaiable? #

Return true if it should redirect, else false


[View source]
def each_redirect(&block : Halite::Request -> Halite::Response) #

Loop each redirect request with block call


[View source]
def endless_loop? #

Check if we got into an endless loop


[View source]
def max_hops : Int32 #

[View source]
def perform(&block : Halite::Request -> Halite::Response) : Halite::Response #

Follows redirects until non-redirect response found


[View source]
def strict : Bool #

[View source]