httparty-responsibly 0.17.0.r1 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9366a457655b713f32e9163acbfcf09e1aec5b8ad843664f1dafa02171ffda9
4
- data.tar.gz: fb62c7d8f4192454f5312d7cd2f2540f365fb6ff22d6794da1e6f9ab460d2529
3
+ metadata.gz: 9d55763430b397dfb7a4a427e64b1d83abd6543fb93fa8ad77ed19d935187296
4
+ data.tar.gz: 1d811112d3f705fa58c9eafb8d593af35e4485f8e3509c1053539011d610a843
5
5
  SHA512:
6
- metadata.gz: 2797c8d27fd23fc0d86ea2335388d37649782bf395c59fcda6b4fa45dc6766038291b79be44614077f02c1a966911d03f845e76f615ee60315918df40ef0ed65
7
- data.tar.gz: 217f9ba516f18298080a69ae914c4aba037ae1b2622ed4ca58694888d583872b198f82f767e069e6ccdfed70e2a3a56f19c81b7bc03fa0cd1787e03e959447a0
6
+ metadata.gz: 25c5aaf3cea1618606343b09fd8087884bb2fc6ebf7882f242c6e9b241ba03c82b39b8c840fa44eebb05c43ad53af04b4eafa28ed1a67a0424646c91ed510e37
7
+ data.tar.gz: 8219e2ebacf83db3fd4322eb7185bc5fa490f4cd2c2a6fc172f3a265c65c65700cfab189bb1052f65c85612bf27d3258eb07d730ba11f301ac8b819489651b91
@@ -1,3 +1,10 @@
1
+ ## 0.17.1
2
+
3
+ * [Pass options to dynamic block headers](https://github.com/jnunemaker/httparty/pull/661)
4
+ * [Normalize urls with URI adapter to allow International Domain Names support](https://github.com/jnunemaker/httparty/pull/668)
5
+ * [Add max_retries support](https://github.com/jnunemaker/httparty/pull/660)
6
+ * [Minize gem size by removing test files](https://github.com/jnunemaker/httparty/pull/658)
7
+
1
8
  ## 0.17.0
2
9
 
3
10
  * [Fix encoding of streamed chunk](https://github.com/jnunemaker/httparty/pull/644)
data/Gemfile CHANGED
@@ -16,6 +16,7 @@ group :test do
16
16
  gem 'aruba'
17
17
  gem 'cucumber', '~> 2.3'
18
18
  gem 'webmock'
19
+ gem 'addressable'
19
20
  end
20
21
 
21
22
  group :development, :test do
@@ -4,10 +4,10 @@ require "httparty/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "httparty-responsibly"
7
- s.version = HTTParty::VERSION + '.r1'
7
+ s.version = HTTParty::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.licenses = ['MIT']
10
- s.authors = ["John Nunemaker", "Sandro Turriate", "James Denness"]
10
+ s.authors = ["John Nunemaker", "Sandro Turriate"]
11
11
  s.email = ["nunemaker@gmail.com", "james@denness.org"]
12
12
  s.homepage = "https://github.com/scarybot/httparty-responsibly"
13
13
  s.summary = "An up-to-date fork of jnunemaker's httparty, without the post-install nonsense."
@@ -17,6 +17,7 @@ require 'httparty/logger/logger'
17
17
  require 'httparty/request/body'
18
18
  require 'httparty/response_fragment'
19
19
  require 'httparty/text_encoder'
20
+ require 'httparty/headers_processor'
20
21
 
21
22
  # @see HTTParty::ClassMethods
22
23
  module HTTParty
@@ -588,28 +589,11 @@ module HTTParty
588
589
 
589
590
  def perform_request(http_method, path, options, &block) #:nodoc:
590
591
  options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
591
- process_headers(options)
592
+ HeadersProcessor.new(headers, options).call
592
593
  process_cookies(options)
593
594
  Request.new(http_method, path, options).perform(&block)
594
595
  end
595
596
 
596
- def process_headers(options)
597
- if options[:headers]
598
- if headers.any?
599
- options[:headers] = headers.merge(options[:headers])
600
- end
601
-
602
- options[:headers] = Utils.stringify_keys(process_dynamic_headers(options[:headers]))
603
- end
604
- end
605
-
606
- def process_dynamic_headers(headers)
607
- headers.each_with_object({}) do |header, processed_headers|
608
- key, value = header
609
- processed_headers[key] = value.respond_to?(:call) ? value.call : value
610
- end
611
- end
612
-
613
597
  def process_cookies(options) #:nodoc:
614
598
  return unless options[:cookies] || default_cookies.any?
615
599
  options[:headers] ||= headers.dup
@@ -137,6 +137,12 @@ module HTTParty
137
137
  end
138
138
  end
139
139
 
140
+ if add_max_retries?(options[:max_retries])
141
+ from_ruby_version('2.5.0', option: :max_retries) do
142
+ http.max_retries = options[:max_retries]
143
+ end
144
+ end
145
+
140
146
  if options[:debug_output]
141
147
  http.set_debug_output(options[:debug_output])
142
148
  end
@@ -177,6 +183,10 @@ module HTTParty
177
183
  timeout && (timeout.is_a?(Integer) || timeout.is_a?(Float))
178
184
  end
179
185
 
186
+ def add_max_retries?(max_retries)
187
+ max_retries && max_retries.is_a?(Integer) && max_retries >= 0
188
+ end
189
+
180
190
  def clean_host(host)
181
191
  strip_ipv6_brackets(host)
182
192
  end
@@ -0,0 +1,30 @@
1
+ module HTTParty
2
+ class HeadersProcessor
3
+ attr_reader :headers, :options
4
+
5
+ def initialize(headers, options)
6
+ @headers = headers
7
+ @options = options
8
+ end
9
+
10
+ def call
11
+ return unless options[:headers]
12
+
13
+ options[:headers] = headers.merge(options[:headers]) if headers.any?
14
+ options[:headers] = Utils.stringify_keys(process_dynamic_headers)
15
+ end
16
+
17
+ private
18
+
19
+ def process_dynamic_headers
20
+ options[:headers].each_with_object({}) do |header, processed_headers|
21
+ key, value = header
22
+ processed_headers[key] = if value.respond_to?(:call)
23
+ value.arity == 0 ? value.call : value.call(options)
24
+ else
25
+ value
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -71,7 +71,7 @@ module HTTParty
71
71
  @path = if uri.is_a?(uri_adapter)
72
72
  uri
73
73
  elsif String.try_convert(uri)
74
- uri_adapter.parse uri
74
+ uri_adapter.parse(uri).normalize
75
75
  else
76
76
  raise ArgumentError,
77
77
  "bad argument (expected #{uri_adapter} object or URI string)"
@@ -95,9 +95,9 @@ module HTTParty
95
95
  end
96
96
 
97
97
  if path.relative? && path.host
98
- new_uri = options[:uri_adapter].parse("#{@last_uri.scheme}:#{path}")
98
+ new_uri = options[:uri_adapter].parse("#{@last_uri.scheme}:#{path}").normalize
99
99
  elsif path.relative?
100
- new_uri = options[:uri_adapter].parse("#{base_uri}#{path}")
100
+ new_uri = options[:uri_adapter].parse("#{base_uri}#{path}").normalize
101
101
  else
102
102
  new_uri = path.clone
103
103
  end
@@ -305,7 +305,7 @@ module HTTParty
305
305
 
306
306
  def handle_host_redirection
307
307
  check_duplicate_location_header
308
- redirect_path = options[:uri_adapter].parse last_response['location']
308
+ redirect_path = options[:uri_adapter].parse(last_response['location']).normalize
309
309
  return if redirect_path.relative? || path.host == redirect_path.host
310
310
  @changed_hosts = true
311
311
  end
@@ -1,3 +1,3 @@
1
1
  module HTTParty
2
- VERSION = "0.17.0"
2
+ VERSION = "0.17.1"
3
3
  end
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httparty-responsibly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0.r1
4
+ version: 0.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  - Sandro Turriate
9
- - James Denness
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2019-07-10 00:00:00.000000000 Z
12
+ date: 2019-12-09 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: multi_xml
@@ -93,6 +92,7 @@ files:
93
92
  - lib/httparty/cookie_hash.rb
94
93
  - lib/httparty/exceptions.rb
95
94
  - lib/httparty/hash_conversions.rb
95
+ - lib/httparty/headers_processor.rb
96
96
  - lib/httparty/logger/apache_formatter.rb
97
97
  - lib/httparty/logger/curl_formatter.rb
98
98
  - lib/httparty/logger/logger.rb
@@ -127,9 +127,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
127
  version: 2.0.0
128
128
  required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - ">"
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
- version: 1.3.1
132
+ version: '0'
133
133
  requirements: []
134
134
  rubygems_version: 3.0.3
135
135
  signing_key: