Module: HTTPX::Plugins::FollowRedirects::RequestMethods

Defined in:
lib/httpx/plugins/follow_redirects.rb,
sig/plugins/follow_redirects.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#root_requestRequest & RequestMethods?

returns the top-most original HTTPX::Request from the redirect chain

Returns:



202
203
204
# File 'lib/httpx/plugins/follow_redirects.rb', line 202

def root_request
  @root_request
end

Instance Method Details

#initializeObject



204
205
206
207
# File 'lib/httpx/plugins/follow_redirects.rb', line 204

def initialize(*)
  super
  @redirect_request = nil
end

#max_redirectsInteger

Returns:

  • (Integer)


234
235
236
# File 'lib/httpx/plugins/follow_redirects.rb', line 234

def max_redirects
  @options.max_redirects || MAX_REDIRECTS
end

#on_response_arrived=(cb) ⇒ Object



209
210
211
212
213
# File 'lib/httpx/plugins/follow_redirects.rb', line 209

def on_response_arrived=(cb)
  @redirect_request.on_response_arrived = cb if @redirect_request

  super
end

#redirect_requestredirect_request

returns the follow-up redirect request, or itself

Returns:



216
217
218
# File 'lib/httpx/plugins/follow_redirects.rb', line 216

def redirect_request
  @redirect_request || self
end

#redirect_request=(req) ⇒ void

This method returns an undefined value.

sets the follow-up redirect request

Parameters:



221
222
223
224
225
226
# File 'lib/httpx/plugins/follow_redirects.rb', line 221

def redirect_request=(req)
  @redirect_request = req
  req.root_request = @root_request || self
  req.on_response_arrived = @on_response_arrived
  @response = nil
end

#responseObject



228
229
230
231
232
# File 'lib/httpx/plugins/follow_redirects.rb', line 228

def response
  return super unless @redirect_request && @response.nil?

  @redirect_request.response
end