typhoeus 1.3.1 → 1.6.0

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -1
  3. data/CONTRIBUTING.md +4 -0
  4. data/README.md +13 -6
  5. data/lib/typhoeus/adapters/faraday.rb +2 -2
  6. data/lib/typhoeus/cache/dalli.rb +3 -1
  7. data/lib/typhoeus/cache/rails.rb +4 -2
  8. data/lib/typhoeus/cache/redis.rb +3 -1
  9. data/lib/typhoeus/config.rb +17 -1
  10. data/lib/typhoeus/easy_factory.rb +27 -1
  11. data/lib/typhoeus/expectation.rb +4 -2
  12. data/lib/typhoeus/hydra/cacheable.rb +1 -1
  13. data/lib/typhoeus/request/cacheable.rb +5 -1
  14. data/lib/typhoeus/request/responseable.rb +1 -1
  15. data/lib/typhoeus/request.rb +2 -0
  16. data/lib/typhoeus/response/informations.rb +57 -0
  17. data/lib/typhoeus/version.rb +1 -1
  18. data/lib/typhoeus.rb +4 -3
  19. data/typhoeus.gemspec +14 -4
  20. metadata +14 -99
  21. data/.gitignore +0 -8
  22. data/.rspec +0 -4
  23. data/.travis.yml +0 -22
  24. data/Gemfile +0 -32
  25. data/Guardfile +0 -9
  26. data/Rakefile +0 -38
  27. data/perf/profile.rb +0 -14
  28. data/perf/vs_nethttp.rb +0 -64
  29. data/spec/rack/typhoeus/middleware/params_decoder/helper_spec.rb +0 -156
  30. data/spec/rack/typhoeus/middleware/params_decoder_spec.rb +0 -31
  31. data/spec/spec_helper.rb +0 -29
  32. data/spec/support/localhost_server.rb +0 -94
  33. data/spec/support/memory_cache.rb +0 -15
  34. data/spec/support/server.rb +0 -116
  35. data/spec/typhoeus/adapters/faraday_spec.rb +0 -339
  36. data/spec/typhoeus/cache/dalli_spec.rb +0 -41
  37. data/spec/typhoeus/cache/redis_spec.rb +0 -41
  38. data/spec/typhoeus/config_spec.rb +0 -15
  39. data/spec/typhoeus/easy_factory_spec.rb +0 -143
  40. data/spec/typhoeus/errors/no_stub_spec.rb +0 -13
  41. data/spec/typhoeus/expectation_spec.rb +0 -280
  42. data/spec/typhoeus/hydra/addable_spec.rb +0 -22
  43. data/spec/typhoeus/hydra/before_spec.rb +0 -98
  44. data/spec/typhoeus/hydra/block_connection_spec.rb +0 -18
  45. data/spec/typhoeus/hydra/cacheable_spec.rb +0 -58
  46. data/spec/typhoeus/hydra/memoizable_spec.rb +0 -53
  47. data/spec/typhoeus/hydra/queueable_spec.rb +0 -98
  48. data/spec/typhoeus/hydra/runnable_spec.rb +0 -137
  49. data/spec/typhoeus/hydra/stubbable_spec.rb +0 -48
  50. data/spec/typhoeus/hydra_spec.rb +0 -22
  51. data/spec/typhoeus/pool_spec.rb +0 -135
  52. data/spec/typhoeus/request/actions_spec.rb +0 -19
  53. data/spec/typhoeus/request/before_spec.rb +0 -93
  54. data/spec/typhoeus/request/block_connection_spec.rb +0 -75
  55. data/spec/typhoeus/request/cacheable_spec.rb +0 -94
  56. data/spec/typhoeus/request/callbacks_spec.rb +0 -91
  57. data/spec/typhoeus/request/marshal_spec.rb +0 -60
  58. data/spec/typhoeus/request/memoizable_spec.rb +0 -34
  59. data/spec/typhoeus/request/operations_spec.rb +0 -101
  60. data/spec/typhoeus/request/responseable_spec.rb +0 -13
  61. data/spec/typhoeus/request/stubbable_spec.rb +0 -45
  62. data/spec/typhoeus/request_spec.rb +0 -232
  63. data/spec/typhoeus/response/header_spec.rb +0 -147
  64. data/spec/typhoeus/response/informations_spec.rb +0 -283
  65. data/spec/typhoeus/response/status_spec.rb +0 -256
  66. data/spec/typhoeus/response_spec.rb +0 -100
  67. data/spec/typhoeus_spec.rb +0 -105
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 417ef8dd5903c12a896c84db243131ec364aec235a44ac32d2590d95f919c10a
4
- data.tar.gz: 62fca0f2cf069282d5c6cdbed018e395b6b40f379cb2d8e45129a156e7aed69a
3
+ metadata.gz: da76288cb44cae7a0b697d2758d41c736ce8cd35b83cc80dcc36b05a46b71601
4
+ data.tar.gz: 00675ad1b7cca1fa8a944c03450d1ff78419df4a734913f9297f00fb890bed41
5
5
  SHA512:
6
- metadata.gz: 9a8e291edbdb7e635f6ffbf085783752e6a0688e342dbec333e2fd85f6d4ac841a4bfca128fe36d4f30d5e0f87a8d124447d77cfd2d15e77c6f29bec4a55f197
7
- data.tar.gz: cf6d163bfb31f1cf77c2faf068601b6c65685d5afaf0f582dadd9505882fb8c567583fd1dad7a47f27210018e992ac300a7803f3870250e1f7a1461111bcab80
6
+ metadata.gz: 931cc5e229d88380754841384cd11aa2e96f851d7ba765420f00e9817d2e05be0b77fbd96d68c21865fd894f34d5708f5c2d306fa0cc9bdbf3c06489103b0b0e
7
+ data.tar.gz: 8b26b43c59ef011e401f6938ba063fceea42288e755f4762a08b5cf44f6d82dbe8f30959ea65a446a73da35127378d2a2e24f6e920fbe067fcaa37f01320cbe5
data/CHANGELOG.md CHANGED
@@ -2,7 +2,78 @@
2
2
 
3
3
  ## Master
4
4
 
5
- [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.1.2...master)
5
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.6.0...master)
6
+
7
+ ## 1.6.0
8
+
9
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.5.0...v1.6.0)
10
+
11
+ * Add Ruby 4.0 to CI matrix and update checkout action to v6.
12
+ ([Geremia Taglialatela](https://github.com/tagliala), [#744](https://github.com/typhoeus/typhoeus/pull/744))
13
+ * Require Ethon >= 0.18.0, removing the upper bound constraint.
14
+ ([Geremia Taglialatela](https://github.com/tagliala), [#742](https://github.com/typhoeus/typhoeus/pull/742))
15
+ * Update RubyDoc link in gemspec metadata.
16
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#737](https://github.com/typhoeus/typhoeus/pull/737))
17
+ * Update gem version badge and remove Code Climate badge.
18
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#736](https://github.com/typhoeus/typhoeus/pull/736))
19
+
20
+ ## 1.5.0
21
+
22
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.4.1...v1.5.0)
23
+
24
+ * Update gemspec with metadata and remove extra files from the bundled gem.
25
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#734](https://github.com/typhoeus/typhoeus/pull/734))
26
+ * Require Ruby 2.6+ and simplify Gemfile.
27
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#733](https://github.com/typhoeus/typhoeus/pull/733))
28
+ * Add support for URI objects in `Typhoeus.stub()`.
29
+ ([Katelyn Schiesser](https://github.com/slowbro), [#732](https://github.com/typhoeus/typhoeus/pull/732))
30
+ * Add explicit require for logger and ostruct gems for Ruby 3.5+ compatibility.
31
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#729](https://github.com/typhoeus/typhoeus/pull/729))
32
+ * Add Ruby 3.4 to CI matrix.
33
+ ([y-yagi](https://github.com/y-yagi), [#728](https://github.com/typhoeus/typhoeus/pull/728))
34
+ * Support curl 8.9 error message changes in tests.
35
+ ([Mamoru TASAKA](https://github.com/mtasaka), [#724](https://github.com/typhoeus/typhoeus/pull/724))
36
+ * Add Ruby 3.2 and 3.3 to CI, drop Ruby 2.5, lock ethon < 0.16.0.
37
+ ([y-yagi](https://github.com/y-yagi), [#716](https://github.com/typhoeus/typhoeus/pull/716))
38
+ * Fix typo in comment: "reponse" → "response".
39
+ ([George Brocklehurst](https://github.com/georgebrock), [#700](https://github.com/typhoeus/typhoeus/pull/700))
40
+
41
+ ## 1.4.1
42
+
43
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.4.0...v1.4.1)
44
+
45
+ * Fix to run CI with Ruby 3.0.
46
+ ([mishina](https://github.com/mishina2228), [#699](https://github.com/typhoeus/typhoeus/pull/699))
47
+ * Replace CI status badge from Travis to GH Actions.
48
+ ([mishina](https://github.com/mishina2228), [#698](https://github.com/typhoeus/typhoeus/pull/698))
49
+ * Added getter for `redirect_url` attribute.
50
+ ([Adrien Rey-Jarthon](https://github.com/jarthod), [#697](https://github.com/typhoeus/typhoeus/pull/697))
51
+ * CI: Adjust ruby versions and MacOS runs.
52
+ ([Holger Arndt](https://github.com/Kjarrigan), [#696](https://github.com/typhoeus/typhoeus/pull/696))
53
+ * Allow performing `curl --upload-file`.
54
+ ([Arian Faurtosh](https://github.com/arianf), [#695](https://github.com/typhoeus/typhoeus/pull/695))
55
+ * Add getter for size_upload, size_download, speed_upload, speed_download values.
56
+ ([Ryo Nakano](https://github.com/ryonkn), [#692](https://github.com/typhoeus/typhoeus/pull/692))
57
+ * Use bundle add instead.
58
+ ([Glauco Custodio](https://github.com/glaucocustodio), [#691](https://github.com/typhoeus/typhoeus/pull/691))
59
+ * Travis -> Github actions.
60
+ ([John Mortlock](https://github.com/jmortlock), [#689](https://github.com/typhoeus/typhoeus/pull/689))
61
+ * Add global timeout and connecttimeout to config.
62
+ ([Teck Wan Wong](https://github.com/teckwan), [#685](https://github.com/typhoeus/typhoeus/pull/685))
63
+ * Update README.md.
64
+ ([Hussain Akram](https://github.com/hussainakram), [#677](https://github.com/typhoeus/typhoeus/pull/677))
65
+
66
+ ## 1.4.0
67
+
68
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.1.2...v1.4.0)
69
+
70
+ #### 1 feature
71
+ - Faraday adapter exceptions namespace compatibility with Faraday v1 ([@iMacTia](https://github.com/iMacTia) in [#616](https://github.com/typhoeus/typhoeus/pull/616))
72
+
73
+ #### 3 Others
74
+ - Yard warning fixes ([@olleolleolle](https://github.com/olleolleolle) in [#622](https://github.com/typhoeus/typhoeus/pull/622))
75
+ - Add more Ruby versions in CI matrix ([@olleolleolle](https://github.com/olleolleolle) in [#623](https://github.com/typhoeus/typhoeus/pull/623))
76
+ - Use of argument passed in function instead of `attr_reader` ([@v-kolesnikov](https://github.com/v-kolesnikov) in [#625](https://github.com/typhoeus/typhoeus/pull/625))
6
77
 
7
78
  ## 1.1.2
8
79
 
data/CONTRIBUTING.md CHANGED
@@ -14,3 +14,7 @@ a test!
14
14
  5. Push to your fork and submit a pull request.
15
15
 
16
16
  And in case we didn't emphasize it enough: we love tests!
17
+
18
+ ## Issue triage [![Open Source Helpers](https://www.codetriage.com/typhoeus/typhoeus/badges/users.svg)](https://www.codetriage.com/typhoeus/typhoeus)
19
+
20
+ You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to typhoeus on CodeTriage](https://www.codetriage.com/typhoeus/typhoeus).
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Typhoeus [![Build Status](https://img.shields.io/travis/typhoeus/typhoeus/master.svg)](https://travis-ci.org/typhoeus/typhoeus) [![Code Climate](https://img.shields.io/codeclimate/github/typhoeus/typhoeus.svg)](https://codeclimate.com/github/typhoeus/typhoeus) [![Gem Version](https://img.shields.io/gem/v/typhoeus.svg)](https://rubygems.org/gems/typhoeus)
1
+ # Typhoeus [![Gem Version](https://badge.fury.io/rb/typhoeus.svg)](https://badge.fury.io/rb/typhoeus) [![CI](https://github.com/typhoeus/typhoeus/actions/workflows/ci.yml/badge.svg)](https://github.com/typhoeus/typhoeus/actions/workflows/ci.yml) [![Experimental](https://github.com/typhoeus/typhoeus/actions/workflows/experimental.yml/badge.svg)](https://github.com/typhoeus/typhoeus/actions/workflows/experimental.yml)
2
2
 
3
3
  Like a modern code version of the mythical beast with 100 serpent heads, Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic.
4
4
 
@@ -19,19 +19,20 @@ hydra.run
19
19
  ```
20
20
 
21
21
  ## Installation
22
-
22
+ Run:
23
23
  ```
24
- gem install typhoeus
24
+ bundle add typhoeus
25
25
  ```
26
26
 
27
+ Or install it yourself as:
28
+
27
29
  ```
28
- gem "typhoeus"
30
+ gem install typhoeus
29
31
  ```
30
32
 
31
33
  ## Project Tracking
32
34
 
33
- * [Documentation](http://rubydoc.info/github/typhoeus/typhoeus/frames/Typhoeus) (GitHub master)
34
- * [Mailing list](http://groups.google.com/group/typhoeus)
35
+ * [API Documentation](https://rubydoc.info/github/typhoeus/typhoeus) (GitHub master)
35
36
 
36
37
  ## Usage
37
38
 
@@ -347,6 +348,8 @@ Typhoeus.get("www.example.com").cached?
347
348
  For use with [Dalli](https://github.com/mperham/dalli):
348
349
 
349
350
  ```ruby
351
+ require "typhoeus/cache/dalli"
352
+
350
353
  dalli = Dalli::Client.new(...)
351
354
  Typhoeus::Config.cache = Typhoeus::Cache::Dalli.new(dalli)
352
355
  ```
@@ -354,12 +357,16 @@ Typhoeus::Config.cache = Typhoeus::Cache::Dalli.new(dalli)
354
357
  For use with Rails:
355
358
 
356
359
  ```ruby
360
+ require "typhoeus/cache/rails"
361
+
357
362
  Typhoeus::Config.cache = Typhoeus::Cache::Rails.new
358
363
  ```
359
364
 
360
365
  For use with [Redis](https://github.com/redis/redis-rb):
361
366
 
362
367
  ```ruby
368
+ require "typhoeus/cache/redis"
369
+
363
370
  redis = Redis.new(...)
364
371
  Typhoeus::Config.cache = Typhoeus::Cache::Redis.new(redis)
365
372
  ```
@@ -97,13 +97,13 @@ module Faraday # :nodoc:
97
97
  if resp.timed_out?
98
98
  env[:typhoeus_timed_out] = true
99
99
  unless parallel?(env)
100
- raise Faraday::Error::TimeoutError, "request timed out"
100
+ raise Faraday::TimeoutError, "request timed out"
101
101
  end
102
102
  elsif (resp.response_code == 0) || ((resp.return_code != :ok) && !resp.mock?)
103
103
  env[:typhoeus_connection_failed] = true
104
104
  env[:typhoeus_return_message] = resp.return_message
105
105
  unless parallel?(env)
106
- raise Faraday::Error::ConnectionFailed, resp.return_message
106
+ raise Faraday::ConnectionFailed, resp.return_message
107
107
  end
108
108
  end
109
109
 
@@ -7,7 +7,9 @@ module Typhoeus
7
7
  #
8
8
  # @param [ Dalli::Client ] client
9
9
  # A connection to the cache server. Defaults to `Dalli::Client.new`
10
- # @param [ Integer ] default_ttl
10
+ # @param [ Hash ] options
11
+ # Options
12
+ # @option options [ Integer ] :default_ttl
11
13
  # The default TTL of cached responses in seconds, for requests which do not set a cache_ttl.
12
14
  def initialize(client = ::Dalli::Client.new, options = {})
13
15
  @client = client
@@ -7,7 +7,9 @@ module Typhoeus
7
7
  #
8
8
  # @param [ ActiveSupport::Cache::Store ] cache
9
9
  # A Rails cache backend. Defaults to Rails.cache.
10
- # @param [ Integer ] default_ttl
10
+ # @param [ Hash ] options
11
+ # Options
12
+ # @option options [ Integer ] :default_ttl
11
13
  # The default TTL of cached responses in seconds, for requests which do not set a cache_ttl.
12
14
  def initialize(cache = ::Rails.cache, options = {})
13
15
  @cache = cache
@@ -19,7 +21,7 @@ module Typhoeus
19
21
  end
20
22
 
21
23
  def set(request, response)
22
- @cache.write(request, response, :expires_in => request.cache_ttl || @default_ttl)
24
+ @cache.write(request.cache_key, response, :expires_in => request.cache_ttl || @default_ttl)
23
25
  end
24
26
  end
25
27
  end
@@ -8,7 +8,9 @@ module Typhoeus
8
8
  # @param [ Redis ] redis
9
9
  # A connection to Redis. Defaults to `Redis.new`, which uses the
10
10
  # `REDIS_URL` environment variable to connect
11
- # @param [ Integer ] default_ttl
11
+ # @param [ Hash ] options
12
+ # Options
13
+ # @option options [ Integer ] :default_ttl
12
14
  # The default TTL of cached responses in seconds, for requests which do not set a cache_ttl.
13
15
  def initialize(redis = ::Redis.new, options = {})
14
16
  @redis = redis
@@ -18,7 +18,7 @@ module Typhoeus
18
18
  # {Typhoeus::Errors::NoStub} error is raised,
19
19
  # when trying to do a real request. It's possible
20
20
  # to work around inside
21
- # {Typhoeus#with_connection}.
21
+ # {Typhoeus.with_connection}.
22
22
  #
23
23
  # @return [ Boolean ]
24
24
  #
@@ -44,6 +44,22 @@ module Typhoeus
44
44
  # @see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTVERBOSE
45
45
  attr_accessor :verbose
46
46
 
47
+ # Defines the default HTTP timeout for the entire request in seconds
48
+ # See README for more details about timeouts
49
+ #
50
+ # @return [ Integer, Float ]
51
+ #
52
+ # @see https://curl.haxx.se/libcurl/c/curl_easy_setopt#CURLOPTTIMEOUT
53
+ attr_accessor :timeout
54
+
55
+ # Defines the default HTTP timeout for the connection phase in seconds
56
+ # See README for more details about timeouts
57
+ #
58
+ # @return [ Integer, Float ]
59
+ #
60
+ # @see https://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUT
61
+ attr_accessor :connecttimeout
62
+
47
63
  # Defines whether requests are cached.
48
64
  #
49
65
  # @return [ Object ]
@@ -78,11 +78,17 @@ module Typhoeus
78
78
  # @return [ Ethon::Easy ] The easy.
79
79
  def get
80
80
  begin
81
+ read_callback_body = request.options.delete(:set_read_callback)
82
+
81
83
  easy.http_request(
82
84
  request.base_url.to_s,
83
85
  request.options.fetch(:method, :get),
84
86
  sanitize(request.options)
85
87
  )
88
+
89
+ # this needs to happen after http_request because
90
+ # ethon will set infilesize to zero if form.empty?
91
+ set_read_callback(read_callback_body) if !read_callback_body.nil?
86
92
  rescue Ethon::Errors::InvalidOption => e
87
93
  help = provide_help(e.message.match(/:\s(\w+)/)[1])
88
94
  raise $!, "#{$!}#{help}", $!.backtrace
@@ -97,7 +103,7 @@ module Typhoeus
97
103
  # set nosignal to true by default
98
104
  # this improves thread safety and timeout behavior
99
105
  sanitized = {:nosignal => true}
100
- request.options.each do |k,v|
106
+ options.each do |k,v|
101
107
  s = k.to_sym
102
108
  next if SANITIZE_IGNORE.include?(s)
103
109
  if new_option = RENAMED_OPTIONS[k.to_sym]
@@ -169,6 +175,26 @@ module Typhoeus
169
175
  end
170
176
  end
171
177
 
178
+ # Sets up an easy upload with CURLOPT_READFUNCTION
179
+ # along with CURLOPT_INFILESIZE_LARGE and CURLOPT_UPLOAD
180
+ #
181
+ # @param [ String/File ] body The body read by the readfunction.
182
+ #
183
+ # @return [ Ethon::Easy ] The easy.
184
+ def set_read_callback(body)
185
+ easy.infilesize_large =
186
+ if body.respond_to?(:bytesize)
187
+ body.bytesize
188
+ elsif body.respond_to?(:size)
189
+ body.size
190
+ end
191
+
192
+ easy.upload = true
193
+ easy.set_read_callback(body)
194
+
195
+ easy
196
+ end
197
+
172
198
  def provide_help(option)
173
199
  if new_option = CHANGED_OPTIONS[option.to_sym]
174
200
  "\nPlease try #{new_option} instead of #{option}." if new_option
@@ -204,9 +204,11 @@ module Typhoeus
204
204
  def url_match?(request_url)
205
205
  case base_url
206
206
  when String
207
- base_url == request_url
207
+ base_url == request_url.to_s
208
208
  when Regexp
209
- base_url === request_url
209
+ base_url === request_url.to_s
210
+ when defined?(URI) && URI
211
+ base_url.to_s == request_url.to_s
210
212
  when nil
211
213
  true
212
214
  else
@@ -2,7 +2,7 @@ module Typhoeus
2
2
  class Hydra
3
3
  module Cacheable
4
4
  def add(request)
5
- if request.cacheable? && response = Typhoeus::Config.cache.get(request)
5
+ if request.cacheable? && response = request.cached_response
6
6
  response.cached = true
7
7
  request.finish(response)
8
8
  dequeue
@@ -11,7 +11,7 @@ module Typhoeus
11
11
  end
12
12
 
13
13
  def run
14
- if cacheable? && response = cache.get(self)
14
+ if response = cached_response
15
15
  response.cached = true
16
16
  finish(response)
17
17
  else
@@ -19,6 +19,10 @@ module Typhoeus
19
19
  end
20
20
  end
21
21
 
22
+ def cached_response
23
+ cacheable? && cache.get(self)
24
+ end
25
+
22
26
  def cache_ttl
23
27
  options[:cache_ttl]
24
28
  end
@@ -1,7 +1,7 @@
1
1
  module Typhoeus
2
2
  class Request
3
3
 
4
- # This module contains logic for having a reponse
4
+ # This module contains logic for having a response
5
5
  # getter and setter.
6
6
  module Responseable
7
7
 
@@ -214,6 +214,8 @@ module Typhoeus
214
214
  options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers] || {})
215
215
  options[:headers]['Expect'] ||= ''
216
216
  options[:verbose] = Typhoeus::Config.verbose if options[:verbose].nil? && !Typhoeus::Config.verbose.nil?
217
+ options[:timeout] = Typhoeus::Config.timeout if options[:timeout].nil? && !Typhoeus::Config.timeout.nil?
218
+ options[:connecttimeout] = Typhoeus::Config.connecttimeout if options[:connecttimeout].nil? && !Typhoeus::Config.connecttimeout.nil?
217
219
  options[:maxredirs] ||= 50
218
220
  options[:proxy] = Typhoeus::Config.proxy unless options.has_key?(:proxy) || Typhoeus::Config.proxy.nil?
219
221
  end
@@ -210,10 +210,67 @@ module Typhoeus
210
210
  options[:redirect_count]
211
211
  end
212
212
 
213
+ # Return the URL a redirect would take you to, had you enabled redirects.
214
+ #
215
+ # @example Get redirect_url.
216
+ # response.redirect_url
217
+ #
218
+ # @return [ String ] The redirect_url.
219
+ def redirect_url
220
+ options[:redirect_url]
221
+ end
222
+
213
223
  def request_size
214
224
  options[:request_size]
215
225
  end
216
226
 
227
+ # Return the bytes, the total amount of bytes that were uploaded
228
+ #
229
+ # @example Get size_upload.
230
+ # response.size_upload
231
+ #
232
+ # @return [ Float ] The size_upload.
233
+ def size_upload
234
+ options[:size_upload]
235
+ end
236
+
237
+
238
+ # Return the bytes, the total amount of bytes that were downloaded.
239
+ # The amount is only for the latest transfer and will be reset again
240
+ # for each new transfer. This counts actual payload data, what's
241
+ # also commonly called body. All meta and header data are excluded
242
+ # and will not be counted in this number.
243
+ #
244
+ # @example Get size_download
245
+ # response.size_download
246
+ #
247
+ # @return [ Float ] The size_download.
248
+ def size_download
249
+ options[:size_download]
250
+ end
251
+
252
+ # Return the bytes/second, the average upload speed that curl
253
+ # measured for the complete upload
254
+ #
255
+ # @example Get speed_upload.
256
+ # response.speed_upload
257
+ #
258
+ # @return [ Float ] The speed_upload.
259
+ def speed_upload
260
+ options[:speed_upload]
261
+ end
262
+
263
+ # Return the bytes/second, the average download speed that curl
264
+ # measured for the complete download
265
+ #
266
+ # @example Get speed_download.
267
+ # response.speed_download
268
+ #
269
+ # @return [ Float ] The speed_download.
270
+ def speed_download
271
+ options[:speed_download]
272
+ end
273
+
217
274
  def debug_info
218
275
  options[:debug_info]
219
276
  end
@@ -1,5 +1,5 @@
1
1
  module Typhoeus
2
2
 
3
3
  # The current Typhoeus version.
4
- VERSION = '1.3.1'
4
+ VERSION = '1.6.0'
5
5
  end
data/lib/typhoeus.rb CHANGED
@@ -127,11 +127,12 @@ module Typhoeus
127
127
  # #=> :ok
128
128
  # end
129
129
  #
130
- # @param [ Block ] block The block to execute.
131
- #
130
+ # @yield Yields control to the block after disabling block_connection.
131
+ # Afterwards, the block_connection is set to its original
132
+ # value.
132
133
  # @return [ Object ] Returns the return value of the block.
133
134
  #
134
- # @see Typhoeus::Config#block_connection
135
+ # @see Typhoeus::Config.block_connection
135
136
  def self.with_connection
136
137
  old = Config.block_connection
137
138
  Config.block_connection = false
data/typhoeus.gemspec CHANGED
@@ -14,12 +14,22 @@ Gem::Specification.new do |s|
14
14
  s.summary = "Parallel HTTP library on top of libcurl multi."
15
15
  s.description = %q{Like a modern code version of the mythical beast with 100 serpent heads, Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic.}
16
16
 
17
- s.required_rubygems_version = ">= 1.3.6"
17
+ s.required_ruby_version = ">= 2.6"
18
18
  s.license = 'MIT'
19
+ s.metadata = {
20
+ 'bug_tracker_uri' => 'https://github.com/typhoeus/typhoeus/issues',
21
+ 'changelog_uri' => "https://github.com/typhoeus/typhoeus/blob/v#{s.version}/CHANGELOG.md",
22
+ 'documentation_uri' => "https://www.rubydoc.info/gems/typhoeus/#{s.version}",
23
+ 'rubygems_mfa_required' => 'true',
24
+ 'source_code_uri' => "https://github.com/typhoeus/typhoeus/tree/v#{s.version}"
25
+ }
19
26
 
20
- s.add_dependency('ethon', [">= 0.9.0"])
27
+ s.add_dependency('ethon', [">= 0.18.0"])
21
28
 
22
- s.files = `git ls-files`.split("\n")
23
- s.test_files = `git ls-files -- spec/*`.split("\n")
29
+ s.files = Dir.chdir(__dir__) do
30
+ `git ls-files -z`.split("\x0").reject do |file|
31
+ file.start_with?(*%w[. Gemfile Guardfile Rakefile perf spec])
32
+ end
33
+ end
24
34
  s.require_path = 'lib'
25
35
  end