Class: Udongo::Redirects::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/udongo/redirects/test.rb

Instance Method Summary collapse

Constructor Details

#initialize(redirect) ⇒ Test



5
6
7
# File 'lib/udongo/redirects/test.rb', line 5

def initialize(redirect)
  @redirect = redirect
end

Instance Method Details

#perform!(base_url: Udongo.config.base.host, follow_location: true) ⇒ Object

follow_location means curl can find out if the eventual endpoint has a 200, a 404, a 500, etc,… It’s a bit slower, but it’s more reliable. (You don’t want to have an OK for a 301 when that 301 leads to a 404)



12
13
14
15
16
17
18
19
# File 'lib/udongo/redirects/test.rb', line 12

def perform!(base_url: Udongo.config.base.host, follow_location: true)
  response = Curl::Easy.perform(base_url + @redirect.source_uri) do |curl|
    curl.head = true
    curl.follow_location = follow_location
  end

  Response.new(response)
end