lib/http/client.rb in http-3.2.1 vs lib/http/client.rb in http-3.3.0

- old
+ new

@@ -23,30 +23,35 @@ @state = :clean end # Make an HTTP request def request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash + opts = @default_options.merge(opts) + req = build_request(verb, uri, opts) + res = perform(req, opts) + return res unless opts.follow + + Redirector.new(opts.follow).perform(req, res) do |request| + perform(request, opts) + end + end + + # Prepare an HTTP request + def build_request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash opts = @default_options.merge(opts) uri = make_request_uri(uri, opts) headers = make_request_headers(opts) body = make_request_body(opts, headers) proxy = opts.proxy - req = HTTP::Request.new( + HTTP::Request.new( :verb => verb, :uri => uri, :headers => headers, :proxy => proxy, :body => body, :auto_deflate => opts.feature(:auto_deflate) ) - - res = perform(req, opts) - return res unless opts.follow - - Redirector.new(opts.follow).perform(req, res) do |request| - perform(request, opts) - end end # @!method persistent? # @see Options#persistent? # @return [Boolean] whenever client is persistent