typhoeus 1.0.1 → 1.0.2
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 +4 -4
- data/.travis.yml +6 -4
- data/CHANGELOG.md +6 -2
- data/Gemfile +5 -1
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/typhoeus/adapters/faraday.rb +1 -0
- data/lib/typhoeus/easy_factory.rb +1 -1
- data/lib/typhoeus/pool.rb +2 -0
- data/lib/typhoeus/response/header.rb +1 -0
- data/lib/typhoeus/version.rb +1 -1
- data/spec/support/server.rb +8 -0
- data/spec/typhoeus/hydra/before_spec.rb +9 -8
- data/spec/typhoeus/hydra/runnable_spec.rb +4 -3
- data/spec/typhoeus/pool_spec.rb +39 -0
- data/spec/typhoeus/request/before_spec.rb +9 -8
- data/typhoeus.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 209f15af78c352c7b5e54d1ad520d6a147eca869
|
4
|
+
data.tar.gz: 1a0a2f51d4ea855c1f50d35036092a4a736abfee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4fcf5b5dd53cf4efd1eb01a96ec3f987fb494563f94a32338e9a97004bf2ba83b519499b8793d1f3b7a8fdfe331c1cafdff1c05c296d8c71d59193e19353e66
|
7
|
+
data.tar.gz: f9b2ac78c68e374543404cdbbc34dfd3a64ff113f75bf5101a82fde17b62819ac8daebafc8e39d819cae88b7a94da071cf261f4febc0e68948449a375eb09da6
|
data/.travis.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
language: ruby
|
1
2
|
script: "bundle exec rake"
|
2
3
|
sudo: false
|
3
4
|
rvm:
|
@@ -5,17 +6,18 @@ rvm:
|
|
5
6
|
- 1.9.2
|
6
7
|
- 1.9.3
|
7
8
|
- 2.0.0
|
9
|
+
- 2.1.8
|
10
|
+
- 2.2.4
|
11
|
+
- 2.3.0
|
8
12
|
- ruby-head
|
9
13
|
- jruby-head
|
10
14
|
- jruby-18mode
|
11
15
|
- jruby-19mode
|
12
|
-
- rbx
|
13
|
-
- rbx-
|
16
|
+
- rbx # It's actually RBX 3
|
17
|
+
- rbx-2
|
14
18
|
matrix:
|
15
19
|
fast_finish: true
|
16
20
|
allow_failures:
|
17
21
|
- rvm: ruby-head
|
18
22
|
- rvm: jruby-head
|
19
|
-
- rvm: rbx-18mode
|
20
|
-
- rvm: rbx-19mode
|
21
23
|
- rvm: ree
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
-
[Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.0.
|
5
|
+
[Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.0.2...master)
|
6
|
+
|
7
|
+
## 1.0.2
|
8
|
+
|
9
|
+
[Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.0.1...v1.0.2)
|
6
10
|
|
7
11
|
## 1.0.1
|
8
12
|
|
@@ -12,7 +16,7 @@
|
|
12
16
|
|
13
17
|
[Full Changelog](http://github.com/typhoeus/typhoeus/compare/v0.8.0...v1.0.0)
|
14
18
|
|
15
|
-
##
|
19
|
+
## 0.8.0
|
16
20
|
|
17
21
|
[Full Changelog](http://github.com/typhoeus/typhoeus/compare/v0.7.3...v0.8.0)
|
18
22
|
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Copyright (c) 2009-2010 Paul Dix
|
2
2
|
Copyright (c) 2011 David Balatero
|
3
|
-
Copyright (c) 2012-
|
3
|
+
Copyright (c) 2012-2016 Hans Hasselberg
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -535,7 +535,7 @@ Copyright © 2009-2010 [Paul Dix](http://www.pauldix.net/)
|
|
535
535
|
|
536
536
|
Copyright © 2011-2012 [David Balatero](https://github.com/dbalatero/)
|
537
537
|
|
538
|
-
Copyright © 2012-
|
538
|
+
Copyright © 2012-2016 [Hans Hasselberg](http://github.com/i0rek/)
|
539
539
|
|
540
540
|
Permission is hereby granted, free of charge, to any person obtaining a
|
541
541
|
copy of this software and associated documentation files (the "Software"),
|
@@ -135,6 +135,7 @@ module Faraday # :nodoc:
|
|
135
135
|
req.options[:proxy] = "#{proxy[:uri].scheme}://#{proxy[:uri].host}:#{proxy[:uri].port}"
|
136
136
|
|
137
137
|
if proxy[:user] && proxy[:password]
|
138
|
+
req.options[:proxyauth] = :any
|
138
139
|
req.options[:proxyuserpwd] = "#{proxy[:user]}:#{proxy[:password]}"
|
139
140
|
end
|
140
141
|
end
|
@@ -121,7 +121,7 @@ module Typhoeus
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def sanitize_timeout!(options, timeout)
|
124
|
-
timeout_ms =
|
124
|
+
timeout_ms = :"#{timeout}_ms"
|
125
125
|
if options[timeout] && options[timeout].round != options[timeout]
|
126
126
|
if !options[timeout_ms]
|
127
127
|
options[timeout_ms] = (options[timeout]*1000).ceil
|
data/lib/typhoeus/pool.rb
CHANGED
@@ -17,6 +17,8 @@ module Typhoeus
|
|
17
17
|
# @example Release easy.
|
18
18
|
# Typhoeus::Pool.release(easy)
|
19
19
|
def self.release(easy)
|
20
|
+
easy.cookielist = "flush" # dump all known cookies to 'cookiejar'
|
21
|
+
easy.cookielist = "all" # remove all cookies from memory for this handle
|
20
22
|
easy.reset
|
21
23
|
@mutex.synchronize { easies << easy }
|
22
24
|
end
|
data/lib/typhoeus/version.rb
CHANGED
data/spec/support/server.rb
CHANGED
@@ -23,6 +23,14 @@ TESTSERVER = Sinatra.new do
|
|
23
23
|
[200, { 'Set-Cookie' => %w[ foo bar ], 'Content-Type' => 'text/plain' }, ['']]
|
24
24
|
end
|
25
25
|
|
26
|
+
get '/cookies-test' do
|
27
|
+
[200, { 'Set-Cookie' => %w(foo=bar bar=foo), 'Content-Type' => 'text/plain' }, ['']]
|
28
|
+
end
|
29
|
+
|
30
|
+
get '/cookies-test2' do
|
31
|
+
[200, { 'Set-Cookie' => %w(foo2=bar bar2=foo), 'Content-Type' => 'text/plain' }, ['']]
|
32
|
+
end
|
33
|
+
|
26
34
|
get '/fail/:number' do
|
27
35
|
if fail_count >= params[:number].to_i
|
28
36
|
"ok"
|
@@ -3,13 +3,14 @@ require 'spec_helper'
|
|
3
3
|
describe Typhoeus::Hydra::Before do
|
4
4
|
let(:request) { Typhoeus::Request.new("") }
|
5
5
|
let(:hydra) { Typhoeus::Hydra.new }
|
6
|
+
let(:receive_counter) { double :mark => :twain }
|
6
7
|
|
7
8
|
describe "#add" do
|
8
9
|
context "when before" do
|
9
10
|
context "when one" do
|
10
11
|
it "executes" do
|
11
|
-
Typhoeus.before { |r|
|
12
|
-
expect(
|
12
|
+
Typhoeus.before { |r| receive_counter.mark }
|
13
|
+
expect(receive_counter).to receive(:mark)
|
13
14
|
hydra.add(request)
|
14
15
|
end
|
15
16
|
|
@@ -54,7 +55,7 @@ describe Typhoeus::Hydra::Before do
|
|
54
55
|
|
55
56
|
context "when multi" do
|
56
57
|
context "when all true" do
|
57
|
-
before { 3.times { Typhoeus.before { |r|
|
58
|
+
before { 3.times { Typhoeus.before { |r| receive_counter.mark } } }
|
58
59
|
|
59
60
|
it "calls super" do
|
60
61
|
expect(Typhoeus::Expectation).to receive(:response_for)
|
@@ -62,16 +63,16 @@ describe Typhoeus::Hydra::Before do
|
|
62
63
|
end
|
63
64
|
|
64
65
|
it "executes all" do
|
65
|
-
expect(
|
66
|
+
expect(receive_counter).to receive(:mark).exactly(3).times
|
66
67
|
hydra.add(request)
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
70
71
|
context "when middle false" do
|
71
72
|
before do
|
72
|
-
Typhoeus.before { |r|
|
73
|
-
Typhoeus.before { |r|
|
74
|
-
Typhoeus.before { |r|
|
73
|
+
Typhoeus.before { |r| receive_counter.mark }
|
74
|
+
Typhoeus.before { |r| receive_counter.mark; nil }
|
75
|
+
Typhoeus.before { |r| receive_counter.mark }
|
75
76
|
end
|
76
77
|
|
77
78
|
it "doesn't call super" do
|
@@ -80,7 +81,7 @@ describe Typhoeus::Hydra::Before do
|
|
80
81
|
end
|
81
82
|
|
82
83
|
it "executes only two" do
|
83
|
-
expect(
|
84
|
+
expect(receive_counter).to receive(:mark).exactly(2).times
|
84
85
|
hydra.add(request)
|
85
86
|
end
|
86
87
|
end
|
@@ -4,6 +4,7 @@ describe Typhoeus::Hydra::Runnable do
|
|
4
4
|
let(:base_url) { "localhost:3001" }
|
5
5
|
let(:options) { {} }
|
6
6
|
let(:hydra) { Typhoeus::Hydra.new(options) }
|
7
|
+
let(:receive_counter) { double :mark => :twain }
|
7
8
|
|
8
9
|
describe "#run" do
|
9
10
|
let(:requests) { [] }
|
@@ -107,7 +108,7 @@ describe Typhoeus::Hydra::Runnable do
|
|
107
108
|
let(:second) { Typhoeus::Request.new("localhost:3001/second") }
|
108
109
|
let(:requests) { [first] }
|
109
110
|
|
110
|
-
before { Typhoeus.on_complete { |r|
|
111
|
+
before { Typhoeus.on_complete { |r| receive_counter.mark } }
|
111
112
|
after { Typhoeus.on_complete.clear; Typhoeus.before.clear }
|
112
113
|
|
113
114
|
context "when real request" do
|
@@ -115,7 +116,7 @@ describe Typhoeus::Hydra::Runnable do
|
|
115
116
|
let(:options) { {} }
|
116
117
|
|
117
118
|
it "calls on_complete callback once for every response" do
|
118
|
-
expect(
|
119
|
+
expect(receive_counter).to receive(:mark).exactly(2).times
|
119
120
|
hydra.run
|
120
121
|
end
|
121
122
|
end
|
@@ -126,7 +127,7 @@ describe Typhoeus::Hydra::Runnable do
|
|
126
127
|
before { Typhoeus.before{ |request| request.finish(Typhoeus::Response.new) } }
|
127
128
|
|
128
129
|
it "simulates real multi run and adds and finishes both requests" do
|
129
|
-
expect(
|
130
|
+
expect(receive_counter).to receive(:mark).exactly(2).times
|
130
131
|
hydra.run
|
131
132
|
end
|
132
133
|
end
|
data/spec/typhoeus/pool_spec.rb
CHANGED
@@ -16,6 +16,45 @@ describe Typhoeus::Pool do
|
|
16
16
|
Typhoeus::Pool.release(easy)
|
17
17
|
end
|
18
18
|
|
19
|
+
it "flush cookies to disk" do
|
20
|
+
expect(easy).to receive(:cookielist=).with('flush')
|
21
|
+
expect(easy).to receive(:reset)
|
22
|
+
expect(easy).to receive(:cookielist=).with('all')
|
23
|
+
Typhoeus::Pool.release(easy)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "writes cookies to disk" do
|
27
|
+
tempfile1 = Tempfile.new('cookies')
|
28
|
+
tempfile2 = Tempfile.new('cookies')
|
29
|
+
|
30
|
+
easy.cookiejar = tempfile1.path
|
31
|
+
easy.url = "localhost:3001/cookies-test"
|
32
|
+
easy.perform
|
33
|
+
|
34
|
+
Typhoeus::Pool.release(easy)
|
35
|
+
|
36
|
+
expect(File.zero?(tempfile1.path)).to be(false)
|
37
|
+
expect(File.read(tempfile1.path)).to match(/\s+foo\s+bar$/)
|
38
|
+
expect(File.read(tempfile1.path)).to match(/\s+bar\s+foo$/)
|
39
|
+
|
40
|
+
# do it again - and check if tempfile1 wasn't change
|
41
|
+
easy.cookiejar = tempfile2.path
|
42
|
+
easy.url = "localhost:3001/cookies-test2"
|
43
|
+
easy.perform
|
44
|
+
|
45
|
+
Typhoeus::Pool.release(easy)
|
46
|
+
|
47
|
+
# tempfile 1
|
48
|
+
expect(File.zero?(tempfile1.path)).to be(false)
|
49
|
+
expect(File.read(tempfile1.path)).to match(/\s+foo\s+bar$/)
|
50
|
+
expect(File.read(tempfile1.path)).to match(/\s+bar\s+foo$/)
|
51
|
+
|
52
|
+
# tempfile2
|
53
|
+
expect(File.zero?(tempfile2.path)).to be(false)
|
54
|
+
expect(File.read(tempfile2.path)).to match(/\s+foo2\s+bar$/)
|
55
|
+
expect(File.read(tempfile2.path)).to match(/\s+bar2\s+foo$/)
|
56
|
+
end
|
57
|
+
|
19
58
|
it "puts easy back into pool" do
|
20
59
|
Typhoeus::Pool.release(easy)
|
21
60
|
expect(Typhoeus::Pool.send(:easies)).to include(easy)
|
@@ -2,13 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Typhoeus::Request::Before do
|
4
4
|
let(:request) { Typhoeus::Request.new("") }
|
5
|
+
let(:receive_counter) { double :mark => :twain }
|
5
6
|
|
6
7
|
describe "#queue" do
|
7
8
|
context "when before" do
|
8
9
|
context "when one" do
|
9
10
|
it "executes" do
|
10
|
-
Typhoeus.before { |r|
|
11
|
-
expect(
|
11
|
+
Typhoeus.before { |r| receive_counter.mark }
|
12
|
+
expect(receive_counter).to receive(:mark)
|
12
13
|
request.run
|
13
14
|
end
|
14
15
|
|
@@ -49,7 +50,7 @@ describe Typhoeus::Request::Before do
|
|
49
50
|
|
50
51
|
context "when multi" do
|
51
52
|
context "when all true" do
|
52
|
-
before { 3.times { Typhoeus.before { |r|
|
53
|
+
before { 3.times { Typhoeus.before { |r| receive_counter.mark } } }
|
53
54
|
|
54
55
|
it "calls super" do
|
55
56
|
expect(Typhoeus::Expectation).to receive(:response_for)
|
@@ -57,16 +58,16 @@ describe Typhoeus::Request::Before do
|
|
57
58
|
end
|
58
59
|
|
59
60
|
it "executes all" do
|
60
|
-
expect(
|
61
|
+
expect(receive_counter).to receive(:mark).exactly(3)
|
61
62
|
request.run
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
66
|
context "when middle false" do
|
66
67
|
before do
|
67
|
-
Typhoeus.before { |r|
|
68
|
-
Typhoeus.before { |r|
|
69
|
-
Typhoeus.before { |r|
|
68
|
+
Typhoeus.before { |r| receive_counter.mark }
|
69
|
+
Typhoeus.before { |r| receive_counter.mark; nil }
|
70
|
+
Typhoeus.before { |r| receive_counter.mark }
|
70
71
|
end
|
71
72
|
|
72
73
|
it "doesn't call super" do
|
@@ -75,7 +76,7 @@ describe Typhoeus::Request::Before do
|
|
75
76
|
end
|
76
77
|
|
77
78
|
it "executes only two" do
|
78
|
-
expect(
|
79
|
+
expect(receive_counter).to receive(:mark).exactly(2).times
|
79
80
|
request.run
|
80
81
|
end
|
81
82
|
end
|
data/typhoeus.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.required_rubygems_version = ">= 1.3.6"
|
18
18
|
s.license = 'MIT'
|
19
19
|
|
20
|
-
s.add_dependency('ethon', [">= 0.
|
20
|
+
s.add_dependency('ethon', [">= 0.9.0"])
|
21
21
|
|
22
22
|
s.files = `git ls-files`.split("\n")
|
23
23
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typhoeus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Balatero
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ethon
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.9.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.
|
28
|
+
version: 0.9.0
|
29
29
|
description: Like a modern code version of the mythical beast with 100 serpent heads,
|
30
30
|
Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic.
|
31
31
|
email:
|