typhoeus 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: c7b2e8c2befcc3ef20e522c6a479ee45daf89f14
4
- data.tar.gz: 59386c8e084d7a61d4c71f6e03bb71e6904fa873
3
+ metadata.gz: 209f15af78c352c7b5e54d1ad520d6a147eca869
4
+ data.tar.gz: 1a0a2f51d4ea855c1f50d35036092a4a736abfee
5
5
  SHA512:
6
- metadata.gz: ea9fd7ddcd70e7e07ed439b8e2d65d87d4d48723a2c23fdd7f01611e1c928601017af4e30ef438790e0e19a1417e409a454218f39a43e20b4aaf53d9dda65842
7
- data.tar.gz: 739e0f9b1407f08605ccaee9921f09a0cb8d2c69d2945f5ae9859b3f6f36d283fe6e35524e72a51124a4c2fd0969e58849a3e5b7412826b5736fef4f75c61502
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-18mode
13
- - rbx-19mode
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.1...master)
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
- ## O.8.0
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
@@ -1,7 +1,11 @@
1
1
  source "https://rubygems.org"
2
2
  gemspec
3
3
 
4
- gem "rake"
4
+ if Gem.ruby_version < Gem::Version.new("1.9.3")
5
+ gem "rake", "< 11"
6
+ else
7
+ gem "rake"
8
+ end
5
9
 
6
10
  group :development, :test do
7
11
  gem "rspec", "~> 3.0"
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-2014 Hans Hasselberg
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-2014 [Hans Hasselberg](http://github.com/i0rek/)
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 = (timeout.to_s + '_ms').to_sym
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
@@ -3,6 +3,7 @@ module Typhoeus
3
3
 
4
4
  # This class represents the response header.
5
5
  # It can be accessed like a hash.
6
+ # Values can be strings (normal case) or arrays of strings (for duplicates headers)
6
7
  #
7
8
  # @api private
8
9
  class Header < Hash
@@ -1,5 +1,5 @@
1
1
  module Typhoeus
2
2
 
3
3
  # The current Typhoeus version.
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
@@ -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| String.new(r.base_url) }
12
- expect(String).to receive(:new).and_return("")
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| String.new(r.base_url) } } }
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(String).to receive(:new).exactly(3).times.and_return("")
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| String.new(r.base_url) }
73
- Typhoeus.before { |r| String.new(r.base_url); nil }
74
- Typhoeus.before { |r| String.new(r.base_url) }
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(String).to receive(:new).exactly(2).times.and_return("")
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| String.new(r.code) } }
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(String).to receive(:new).exactly(2).times
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(String).to receive(:new).exactly(2).times
130
+ expect(receive_counter).to receive(:mark).exactly(2).times
130
131
  hydra.run
131
132
  end
132
133
  end
@@ -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| String.new(r.base_url) }
11
- expect(String).to receive(:new).and_return("")
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| String.new(r.base_url) } } }
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(String).to receive(:new).exactly(3).times.and_return("")
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| String.new(r.base_url) }
68
- Typhoeus.before { |r| String.new(r.base_url); nil }
69
- Typhoeus.before { |r| String.new(r.base_url) }
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(String).to receive(:new).exactly(2).times.and_return("")
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.8.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.1
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-01-11 00:00:00.000000000 Z
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.8.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.8.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: