Class: HTTP::Session::Context::FollowContext

Inherits:
Object
  • Object
show all
Defined in:
lib/http/session/context/follow_context.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ FollowContext

Returns a new instance of FollowContext.



4
5
6
7
8
# File 'lib/http/session/context/follow_context.rb', line 4

def initialize(opts)
  @request = opts[:request]
  @verb = opts[:verb]
  @uri = opts[:uri]
end

Instance Method Details

#cross_origin?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/http/session/context/follow_context.rb', line 14

def cross_origin?
  !same_origin?
end

#same_origin?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/http/session/context/follow_context.rb', line 10

def same_origin?
  @request.uri.origin == @uri.origin
end

#should_drop_body?Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/http/session/context/follow_context.rb', line 18

def should_drop_body?
  @verb == :get &&
    HTTP::Session::Redirector::UNSAFE_VERBS.include?(@request.verb)
end