Skip to content

Commit

Permalink
feat: HTTPClient.new accepts initialization block
Browse files Browse the repository at this point in the history
HTTPClient.new { |c| c.debug_dev = STDERR }.get("...")
  • Loading branch information
Hiroshi Nakamura committed Jan 20, 2015
1 parent 006a596 commit e11c780
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def attr_proxy(symbol, assignable = false)
# HTTP client must send Authorization header after it gets 401 error
# from server from security reason. But in some situation (e.g. API
# client) you might want to send Authorization from the beginning.
def initialize(*args)
def initialize(*args, &block)
proxy, agent_name, from, base_url, default_header, force_basic_auth =
keyword_argument(args, :proxy, :agent_name, :from, :base_url, :default_header, :force_basic_auth)
@proxy = nil # assigned later.
Expand All @@ -420,6 +420,7 @@ def initialize(*args)
load_environment
self.proxy = proxy if proxy
keep_webmock_compat
instance_eval &block if block
end

# webmock 1.6.2 depends on HTTP::Message#body.content to work.
Expand Down

0 comments on commit e11c780

Please sign in to comment.