Module: HTTPX::Plugins::FollowRedirects

Defined in:
lib/httpx/plugins/follow_redirects.rb

Overview

This plugin adds support for following redirect (status 30X) responses.

It has an upper bound of followed redirects (see MAX_REDIRECTS), after which it will return the last redirect response. It will not raise an exception.

It also doesn’t follow insecure redirects (https -> http) by default (see follow_insecure_redirects).

gitlab.com/honeyryderchuck/httpx/wikis/Follow-Redirects

Defined Under Namespace

Modules: InstanceMethods, RequestMethods

Constant Summary collapse

MAX_REDIRECTS =
3
REDIRECT_STATUS =
(300..399).freeze

Class Method Summary collapse

Class Method Details

.extra_options(options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/httpx/plugins/follow_redirects.rb', line 20

def self.extra_options(options)
  Class.new(options.class) do
    def_option(:max_redirects) do |num|
      num = Integer(num)
      raise Error, ":max_redirects must be positive" unless num.positive?

      num
    end

    def_option(:follow_insecure_redirects)
  end.new(options)
end