Sha256: 99096fa902d80887732f8b5e924b325d6d71fb264fc223f5bcf413c0d91e1313

Contents?: true

Size: 632 Bytes

Versions: 3

Compression:

Stored size: 632 Bytes

Contents

require 'curb'

module Udongo::Redirects
  class Test
    def initialize(redirect)
      @redirect = redirect
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
udongo-7.9.0 lib/udongo/redirects/test.rb
udongo-7.8.1 lib/udongo/redirects/test.rb
udongo-7.8.0 lib/udongo/redirects/test.rb