typhoeus 1.3.1 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 417ef8dd5903c12a896c84db243131ec364aec235a44ac32d2590d95f919c10a
4
- data.tar.gz: 62fca0f2cf069282d5c6cdbed018e395b6b40f379cb2d8e45129a156e7aed69a
3
+ metadata.gz: b1a6b0485477d252e7eb99852bec27994e9c23aa54e7d376cd24bc07d3639d5c
4
+ data.tar.gz: d2dbaf34e81e7a906dbf254d0d1aa1d6028c10a08605b6dc6261c282bfc39abd
5
5
  SHA512:
6
- metadata.gz: 9a8e291edbdb7e635f6ffbf085783752e6a0688e342dbec333e2fd85f6d4ac841a4bfca128fe36d4f30d5e0f87a8d124447d77cfd2d15e77c6f29bec4a55f197
7
- data.tar.gz: cf6d163bfb31f1cf77c2faf068601b6c65685d5afaf0f582dadd9505882fb8c567583fd1dad7a47f27210018e992ac300a7803f3870250e1f7a1461111bcab80
6
+ metadata.gz: 711db47d856f75d5eb730e11161e02a6a6f6c6d9e966aeec3ace577d250d57a790c2d0d5ade86fda425bff6b5f6d5c77079107a3f41a2379d4bff9cd802ca712
7
+ data.tar.gz: 52cfa55fe418b64ed16e094a497d6fc72092b8d5745d81860aead9e35a6dba403fb2375674ca652ba6bb8e5acac29ed5ce03161c2c68dc0f1de9d44ad65ac277
@@ -0,0 +1,30 @@
1
+ name: CI
2
+ on: [push, pull_request]
3
+ jobs:
4
+ build:
5
+ env:
6
+ BUNDLE_GEMFILE: Gemfile
7
+ runs-on: ${{ matrix.os }}-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ os: [ubuntu, macos]
12
+ ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', truffleruby]
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - name: Install libcurl header
16
+ run: |
17
+ if ${{ matrix.os == 'macos' }}
18
+ then
19
+ brew install curl
20
+ else
21
+ sudo apt update && sudo apt install -y --no-install-recommends libcurl4-openssl-dev
22
+ fi
23
+ - name: Set up Ruby ${{ matrix.ruby-version }}
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby-version }}
27
+ bundler-cache: true
28
+ - name: Run tests
29
+ run: |
30
+ bundle exec rake
@@ -0,0 +1,33 @@
1
+ name: Experimental
2
+ on: [push, pull_request]
3
+ jobs:
4
+ build:
5
+ env:
6
+ BUNDLE_GEMFILE: Gemfile
7
+ runs-on: ${{ matrix.os }}-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ os: [ubuntu, macos]
12
+ ruby-version:
13
+ - ruby-head
14
+ - jruby-head
15
+ - truffleruby-head
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ - name: Install libcurl header
19
+ run: |
20
+ if ${{ matrix.os == 'macos' }}
21
+ then
22
+ brew install curl
23
+ else
24
+ sudo apt update && sudo apt install -y --no-install-recommends libcurl4-openssl-dev
25
+ fi
26
+ - name: Set up Ruby ${{ matrix.ruby-version }}
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby-version }}
30
+ bundler-cache: true
31
+ - name: Run tests
32
+ run: |
33
+ bundle exec rake
data/CHANGELOG.md CHANGED
@@ -2,7 +2,23 @@
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.4.1...master)
6
+
7
+ ## 1.4.1
8
+
9
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.4.0...v1.4.1)
10
+
11
+ ## 1.4.0
12
+
13
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.1.2...v1.4.0)
14
+
15
+ #### 1 feature
16
+ - Faraday adapter exceptions namespace compatibility with Faraday v1 ([@iMacTia](https://github.com/iMacTia) in [#616](https://github.com/typhoeus/typhoeus/pull/616))
17
+
18
+ #### 3 Others
19
+ - Yard warning fixes ([@olleolleolle](https://github.com/olleolleolle) in [#622](https://github.com/typhoeus/typhoeus/pull/622))
20
+ - Add more Ruby versions in CI matrix ([@olleolleolle](https://github.com/olleolleolle) in [#623](https://github.com/typhoeus/typhoeus/pull/623))
21
+ - 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
22
 
7
23
  ## 1.1.2
8
24
 
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/Gemfile CHANGED
@@ -15,10 +15,14 @@ group :development, :test do
15
15
  gem "sinatra", "~> 1.3"
16
16
 
17
17
  if Gem.ruby_version >= Gem::Version.new("1.9.0")
18
- gem "faraday", ">= 0.9"
18
+ gem "faraday", ">= 0.9", "< 2.0"
19
19
  gem "dalli", "~> 2.0"
20
20
  end
21
21
 
22
+ if Gem.ruby_version >= Gem::Version.new("3.0.0")
23
+ gem 'webrick'
24
+ end
25
+
22
26
  gem "redis", "~> 3.0"
23
27
 
24
28
  if RUBY_PLATFORM == "java"
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 [![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) [![Code Climate](https://img.shields.io/codeclimate/maintainability/typhoeus/typhoeus.svg)](https://codeclimate.com/github/typhoeus/typhoeus) [![Gem Version](https://img.shields.io/gem/v/typhoeus.svg)](https://rubygems.org/gems/typhoeus)
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/frames/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
@@ -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
@@ -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.4.1'
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
@@ -163,7 +163,7 @@ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("1.9.0")
163
163
 
164
164
  context "when not parallel" do
165
165
  it "raises an error" do
166
- expect { conn.get("/") }.to raise_error(Faraday::Error::ConnectionFailed, "No error")
166
+ expect { conn.get("/") }.to raise_error(Faraday::ConnectionFailed, "No error")
167
167
  end
168
168
  end
169
169
  end
@@ -4,6 +4,7 @@ describe Typhoeus::Hydra::Cacheable do
4
4
  let(:base_url) { "localhost:3001" }
5
5
  let(:hydra) { Typhoeus::Hydra.new() }
6
6
  let(:request) { Typhoeus::Request.new(base_url, {:method => :get}) }
7
+ let(:response) { Typhoeus::Response.new }
7
8
  let(:cache) { MemoryCache.new }
8
9
 
9
10
  describe "add" do
@@ -24,7 +25,6 @@ describe Typhoeus::Hydra::Cacheable do
24
25
  end
25
26
 
26
27
  context "when request in memory" do
27
- let(:response) { Typhoeus::Response.new }
28
28
  before { cache.memory[request] = response }
29
29
 
30
30
  it "returns response with cached status" do
@@ -53,6 +53,36 @@ describe Typhoeus::Hydra::Cacheable do
53
53
  end
54
54
  end
55
55
  end
56
+
57
+ context "when cache is specified on a request" do
58
+ before { Typhoeus::Config.cache = false }
59
+
60
+ context "when cache is false" do
61
+ let(:non_cached_request) { Typhoeus::Request.new(base_url, {:method => :get, :cache => false}) }
62
+
63
+ it "initiates an HTTP call" do
64
+ expect(Typhoeus::EasyFactory).to receive(:new).with(non_cached_request, hydra).and_call_original
65
+
66
+ hydra.add(non_cached_request)
67
+ end
68
+ end
69
+
70
+ context "when cache is defined" do
71
+ let(:cached_request) { Typhoeus::Request.new(base_url, {:method => :get, :cache => cache}) }
72
+
73
+ before { cache.memory[cached_request] = response }
74
+
75
+ it "uses the cache instead of making a new request" do
76
+ expect(Typhoeus::EasyFactory).not_to receive(:new)
77
+
78
+ hydra.add(cached_request)
79
+
80
+ expect(cached_request.response).to be_cached
81
+ expect(cached_request.response).to eq(response)
82
+ end
83
+ end
84
+ end
85
+
56
86
  end
57
87
  end
58
88
  end
@@ -88,12 +88,14 @@ describe Typhoeus::Pool do
88
88
 
89
89
  context "when threaded access" do
90
90
  it "creates correct number of easies" do
91
- array = []
91
+ queue = Queue.new
92
92
  (0..9).map do |n|
93
93
  Thread.new do
94
- array << Typhoeus::Pool.get
94
+ queue.enq(Typhoeus::Pool.get)
95
95
  end
96
96
  end.map(&:join)
97
+
98
+ array = Array.new(queue.size) { queue.pop }
97
99
  expect(array.uniq.size).to eq(10)
98
100
  end
99
101
  end
@@ -2,7 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe Typhoeus::Request do
4
4
  let(:base_url) { "localhost:3001" }
5
- let(:options) { {:verbose => true, :headers => { 'User-Agent' => "Fubar", 'Expect' => "" }, :maxredirs => 50} }
5
+ let(:options) do
6
+ {
7
+ verbose: true,
8
+ headers: { "User-Agent" => "Fubar", "Expect" => "" },
9
+ maxredirs: 50
10
+ }
11
+ end
6
12
  let(:request) { Typhoeus::Request.new(base_url, options) }
7
13
 
8
14
  describe ".url" do
@@ -95,6 +101,24 @@ describe Typhoeus::Request do
95
101
  end
96
102
  end
97
103
 
104
+ context "when Config.timeout set" do
105
+ before { Typhoeus.configure { |config| config.timeout = 10 } }
106
+ after { Typhoeus.configure { |config| config.timeout = nil } }
107
+
108
+ it "respects configuration" do
109
+ expect(request.options[:timeout]).to eq(10)
110
+ end
111
+ end
112
+
113
+ context "when Config.connecttimeout set" do
114
+ before { Typhoeus.configure { |config| config.connecttimeout = 10 } }
115
+ after { Typhoeus.configure { |config| config.connecttimeout = nil } }
116
+
117
+ it "respects configuration" do
118
+ expect(request.options[:connecttimeout]).to eq(10)
119
+ end
120
+ end
121
+
98
122
  context "when maxredirs" do
99
123
  context "when not set" do
100
124
  it "defaults to 50" do
@@ -195,6 +195,14 @@ describe Typhoeus::Response::Informations do
195
195
  end
196
196
  end
197
197
 
198
+ describe "#redirect_url" do
199
+ let(:options) { { :redirect_url => "http://www.example.com" } }
200
+
201
+ it "returns redirect_url from options" do
202
+ expect(response.redirect_url).to eq("http://www.example.com")
203
+ end
204
+ end
205
+
198
206
  describe "#request_size" do
199
207
  let(:options) { { :request_size => 2 } }
200
208
 
@@ -203,6 +211,38 @@ describe Typhoeus::Response::Informations do
203
211
  end
204
212
  end
205
213
 
214
+ describe "#size_upload" do
215
+ let(:options) { { :size_upload => 2.0 } }
216
+
217
+ it "returns size_upload from options" do
218
+ expect(response.size_upload).to eq(2.0)
219
+ end
220
+ end
221
+
222
+ describe "#size_download" do
223
+ let(:options) { { :size_download => 2.0 } }
224
+
225
+ it "returns size_download from options" do
226
+ expect(response.size_download).to eq(2.0)
227
+ end
228
+ end
229
+
230
+ describe "#speed_upload" do
231
+ let(:options) { { :speed_upload => 2.0 } }
232
+
233
+ it "returns speed_upload from options" do
234
+ expect(response.speed_upload).to eq(2.0)
235
+ end
236
+ end
237
+
238
+ describe "#speed_download" do
239
+ let(:options) { { :speed_download => 2.0 } }
240
+
241
+ it "returns speed_download from options" do
242
+ expect(response.speed_download).to eq(2.0)
243
+ end
244
+ end
245
+
206
246
  describe "#headers" do
207
247
  context "when no response_headers" do
208
248
  it "returns nil" do
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typhoeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Balatero
8
8
  - Paul Dix
9
9
  - Hans Hasselberg
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-11-06 00:00:00.000000000 Z
13
+ date: 2023-11-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ethon
@@ -34,9 +34,10 @@ executables: []
34
34
  extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
+ - ".github/workflows/ci.yml"
38
+ - ".github/workflows/experimental.yml"
37
39
  - ".gitignore"
38
40
  - ".rspec"
39
- - ".travis.yml"
40
41
  - CHANGELOG.md
41
42
  - CONTRIBUTING.md
42
43
  - Gemfile
@@ -134,7 +135,7 @@ homepage: https://github.com/typhoeus/typhoeus
134
135
  licenses:
135
136
  - MIT
136
137
  metadata: {}
137
- post_install_message:
138
+ post_install_message:
138
139
  rdoc_options: []
139
140
  require_paths:
140
141
  - lib
@@ -149,9 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
150
  - !ruby/object:Gem::Version
150
151
  version: 1.3.6
151
152
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.7.6
154
- signing_key:
153
+ rubygems_version: 3.3.7
154
+ signing_key:
155
155
  specification_version: 4
156
156
  summary: Parallel HTTP library on top of libcurl multi.
157
157
  test_files:
data/.travis.yml DELETED
@@ -1,22 +0,0 @@
1
- language: ruby
2
- script: "bundle exec rake"
3
- sudo: false
4
- rvm:
5
- - 1.8.7
6
- - 1.9.2
7
- - 1.9.3
8
- - 2.0.0
9
- - 2.1.8
10
- - 2.2.4
11
- - 2.3.0
12
- - 2.4.1
13
- - ruby-head
14
- - jruby-head
15
- - jruby-18mode
16
- - jruby-19mode
17
- matrix:
18
- fast_finish: true
19
- allow_failures:
20
- - rvm: ruby-head
21
- - rvm: jruby-head
22
- - rvm: ree