mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
deprecating the .plugins, as it's not compatible with sending plugin options
This commit is contained in:
parent
4724cbee33
commit
4451218300
@ -28,13 +28,20 @@ module HTTPX
|
||||
branch(default_options).wrap(&blk)
|
||||
end
|
||||
|
||||
def plugin(*plugins)
|
||||
def plugin(*args, **opts)
|
||||
klass = is_a?(Session) ? self.class : Session
|
||||
klass = Class.new(klass)
|
||||
klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options))
|
||||
klass.plugins(plugins).new
|
||||
klass.plugin(*args, **opts).new
|
||||
end
|
||||
|
||||
# deprecated
|
||||
def plugins(*args, **opts)
|
||||
klass = is_a?(Session) ? self.class : Session
|
||||
klass = Class.new(klass)
|
||||
klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options))
|
||||
klass.plugins(*args, **opts).new
|
||||
end
|
||||
alias_method :plugins, :plugin
|
||||
|
||||
def with(options, &blk)
|
||||
branch(default_options.merge(options), &blk)
|
||||
|
@ -251,12 +251,15 @@ module HTTPX
|
||||
self
|
||||
end
|
||||
|
||||
# :nocov:
|
||||
def plugins(pls)
|
||||
warn ":#{__method__} is deprecated, use :plugin instead"
|
||||
pls.each do |pl, *args|
|
||||
plugin(pl, *args)
|
||||
end
|
||||
self
|
||||
end
|
||||
# :nocov:
|
||||
end
|
||||
|
||||
plugin(:proxy) unless ENV.grep(/https?_proxy$/i).empty?
|
||||
|
@ -43,7 +43,7 @@ module Requests
|
||||
end
|
||||
|
||||
def test_plugin_cookies_follow
|
||||
session = HTTPX.plugins(:follow_redirects, :cookies)
|
||||
session = HTTPX.plugin(:follow_redirects).plugin(:cookies)
|
||||
session_cookies = { "a" => "b", "c" => "d" }
|
||||
session_uri = cookies_set_uri(session_cookies)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user