Module: HTTPX::Plugins::FollowRedirects::RequestMethods
- Defined in:
- lib/httpx/plugins/follow_redirects.rb,
sig/plugins/follow_redirects.rbs
Instance Attribute Summary collapse
-
#root_request ⇒ Request & RequestMethods?
returns the top-most original HTTPX::Request from the redirect chain.
Instance Method Summary collapse
- #emit_response(response) ⇒ Object
- #initialize ⇒ Object
- #max_redirects ⇒ Integer
- #on_response_arrived=(cb) ⇒ Object
-
#redirect_request ⇒ redirect_request
returns the follow-up redirect request, or itself.
-
#redirect_request=(req) ⇒ void
sets the follow-up redirect request.
- #response ⇒ Object
- #response=(response) ⇒ Object
Instance Attribute Details
#root_request ⇒ Request & RequestMethods?
returns the top-most original HTTPX::Request from the redirect chain
204 205 206 |
# File 'lib/httpx/plugins/follow_redirects.rb', line 204 def root_request @root_request end |
Instance Method Details
#emit_response(response) ⇒ Object
242 243 244 245 246 |
# File 'lib/httpx/plugins/follow_redirects.rb', line 242 def emit_response(response) return super unless @redirect_request && @response.nil? @redirect_request.emit_response(response) end |
#initialize ⇒ Object
206 207 208 209 |
# File 'lib/httpx/plugins/follow_redirects.rb', line 206 def initialize(*) super @redirect_request = nil end |
#max_redirects ⇒ Integer
248 249 250 |
# File 'lib/httpx/plugins/follow_redirects.rb', line 248 def max_redirects @options.max_redirects || MAX_REDIRECTS end |
#on_response_arrived=(cb) ⇒ Object
211 212 213 214 215 |
# File 'lib/httpx/plugins/follow_redirects.rb', line 211 def on_response_arrived=(cb) @redirect_request.on_response_arrived = cb if @redirect_request super end |
#redirect_request ⇒ redirect_request
returns the follow-up redirect request, or itself
218 219 220 |
# File 'lib/httpx/plugins/follow_redirects.rb', line 218 def redirect_request @redirect_request || self end |
#redirect_request=(req) ⇒ void
This method returns an undefined value.
sets the follow-up redirect request
223 224 225 226 227 228 |
# File 'lib/httpx/plugins/follow_redirects.rb', line 223 def redirect_request=(req) @redirect_request = req req.root_request = @root_request || self req.on_response_arrived = @on_response_arrived @response = nil end |
#response ⇒ Object
230 231 232 233 234 |
# File 'lib/httpx/plugins/follow_redirects.rb', line 230 def response return super unless @redirect_request && @response.nil? @redirect_request.response end |
#response=(response) ⇒ Object
236 237 238 239 240 |
# File 'lib/httpx/plugins/follow_redirects.rb', line 236 def response=(response) return super unless @redirect_request && @response.nil? # rubocop:disable Lint/ReturnInVoidContext @redirect_request.response = response end |