typhoeus 1.0.2 → 1.1.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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +9 -1
- data/Gemfile +3 -2
- data/README.md +0 -13
- data/lib/typhoeus/adapters/faraday.rb +1 -0
- data/lib/typhoeus/config.rb +7 -0
- data/lib/typhoeus/request.rb +2 -0
- data/lib/typhoeus/response/header.rb +1 -0
- data/lib/typhoeus/version.rb +1 -1
- data/spec/typhoeus/adapters/faraday_spec.rb +31 -0
- data/spec/typhoeus/config_spec.rb +1 -1
- data/spec/typhoeus/request_spec.rb +21 -3
- data/spec/typhoeus/response/header_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e844646bbdb137fea0fc50cf6c8d618ed1ef675
|
4
|
+
data.tar.gz: f2eef78a13606b8c957cae48afea61fe1118117b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e2cd0fdcdf92be70c916a75b95a8d3f6baf794e760c14f8dda7e0812ba965f686a9d720176e082e3cbe6b0cacd3013f79ea8f52deae7242f4728b44dc08b608
|
7
|
+
data.tar.gz: a76443341afde890cc9bfc6feb4e350effc9f8be7f36c5f61eb25d9afd0fcbeba182c675aa7a09bfb3ba514c6269543e4f0d2e5c81f0958c4986e0d9d06a9cd8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,15 @@
|
|
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.1.0...master)
|
6
|
+
|
7
|
+
## 1.1.0
|
8
|
+
|
9
|
+
[Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.0.2...v1.1.0)
|
10
|
+
|
11
|
+
* Unless specified `Expect` header is set to be empty to avoid `100 continue`
|
12
|
+
to be set when using `PUT`
|
13
|
+
* Add global config option `Typhoeus::Config.proxy`
|
6
14
|
|
7
15
|
## 1.0.2
|
8
16
|
|
data/Gemfile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
if Gem.ruby_version < Gem::Version.new("
|
4
|
+
if Gem.ruby_version < Gem::Version.new("2.0.0")
|
5
5
|
gem "rake", "< 11"
|
6
|
+
gem "json", "< 2"
|
6
7
|
else
|
8
|
+
gem "json"
|
7
9
|
gem "rake"
|
8
10
|
end
|
9
11
|
|
@@ -11,7 +13,6 @@ group :development, :test do
|
|
11
13
|
gem "rspec", "~> 3.0"
|
12
14
|
|
13
15
|
gem "sinatra", "~> 1.3"
|
14
|
-
gem "json"
|
15
16
|
gem "faraday", ">= 0.9"
|
16
17
|
|
17
18
|
if RUBY_PLATFORM == "java"
|
data/README.md
CHANGED
@@ -2,16 +2,6 @@
|
|
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
|
|
5
|
-
# Typhoeus needs your help!
|
6
|
-
|
7
|
-
I don't have enough time, but I think this is a nice project! If you or your company is using Typhoeus you should help keeping it alive! Pick any of:
|
8
|
-
|
9
|
-
* add docs
|
10
|
-
* respond to issues
|
11
|
-
* add features
|
12
|
-
|
13
|
-
Or send me an email! I would be more than happy to help getting you up to speed!
|
14
|
-
|
15
5
|
## Example
|
16
6
|
|
17
7
|
A single request:
|
@@ -554,6 +544,3 @@ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
554
544
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
555
545
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
556
546
|
OTHER DEALINGS IN THE SOFTWARE.
|
557
|
-
|
558
|
-
|
559
|
-
[](https://bitdeli.com/free "Bitdeli Badge")
|
data/lib/typhoeus/config.rb
CHANGED
@@ -58,5 +58,12 @@ module Typhoeus
|
|
58
58
|
#
|
59
59
|
# @see Typhoeus::Request#set_defaults
|
60
60
|
attr_accessor :user_agent
|
61
|
+
|
62
|
+
# Defines wether to use a proxy server for every request.
|
63
|
+
#
|
64
|
+
# @return [ String ]
|
65
|
+
#
|
66
|
+
# @see Typhoeus::Request#set_defaults
|
67
|
+
attr_accessor :proxy
|
61
68
|
end
|
62
69
|
end
|
data/lib/typhoeus/request.rb
CHANGED
@@ -212,8 +212,10 @@ module Typhoeus
|
|
212
212
|
default_user_agent = Config.user_agent || Typhoeus::USER_AGENT
|
213
213
|
|
214
214
|
options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers] || {})
|
215
|
+
options[:headers]['Expect'] ||= ''
|
215
216
|
options[:verbose] = Typhoeus::Config.verbose if options[:verbose].nil? && !Typhoeus::Config.verbose.nil?
|
216
217
|
options[:maxredirs] ||= 50
|
218
|
+
options[:proxy] = Typhoeus::Config.proxy unless options.has_key?(:proxy) || Typhoeus::Config.proxy.nil?
|
217
219
|
end
|
218
220
|
end
|
219
221
|
end
|
data/lib/typhoeus/version.rb
CHANGED
@@ -123,6 +123,37 @@ describe Faraday::Adapter::Typhoeus do
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
context "when the connection failed" do
|
127
|
+
before do
|
128
|
+
stub = Typhoeus::Response.new \
|
129
|
+
:response_code => 0,
|
130
|
+
:return_code => 0,
|
131
|
+
:mock => true
|
132
|
+
|
133
|
+
Typhoeus.stub(base_url + '/').and_return(stub)
|
134
|
+
end
|
135
|
+
|
136
|
+
context "when parallel" do
|
137
|
+
it "isn't successful" do
|
138
|
+
response = nil
|
139
|
+
conn.in_parallel { response = conn.get("/") }
|
140
|
+
expect(response.success?).to be_falsey
|
141
|
+
end
|
142
|
+
|
143
|
+
it "translates the response code into an error message" do
|
144
|
+
response = nil
|
145
|
+
conn.in_parallel { response = conn.get("/") }
|
146
|
+
expect(response.env[:typhoeus_return_message]).to eq("No error")
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context "when not parallel" do
|
151
|
+
it "raises an error" do
|
152
|
+
expect { conn.get("/") }.to raise_error(Faraday::Error::ConnectionFailed, "No error")
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
126
157
|
describe "#configure_socket" do
|
127
158
|
let(:env) { { :request => { :bind => { :host => "interface" } } } }
|
128
159
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Typhoeus::Config do
|
4
4
|
let(:config) { Typhoeus::Config }
|
5
5
|
|
6
|
-
[:block_connection, :memoize, :verbose, :cache, :user_agent].each do |name|
|
6
|
+
[:block_connection, :memoize, :verbose, :cache, :user_agent, :proxy].each do |name|
|
7
7
|
it "responds to #{name}" do
|
8
8
|
expect(config).to respond_to(name)
|
9
9
|
end
|
@@ -2,7 +2,7 @@ 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" }, :maxredirs => 50} }
|
5
|
+
let(:options) { {:verbose => true, :headers => { 'User-Agent' => "Fubar", 'Expect' => "" }, :maxredirs => 50} }
|
6
6
|
let(:request) { Typhoeus::Request.new(base_url, options) }
|
7
7
|
|
8
8
|
describe ".url" do
|
@@ -110,6 +110,23 @@ describe Typhoeus::Request do
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
113
|
+
|
114
|
+
context "when Config.proxy set" do
|
115
|
+
before { Typhoeus.configure { |config| config.proxy = "http://proxy.internal" } }
|
116
|
+
after { Typhoeus.configure { |config| config.proxy = nil } }
|
117
|
+
|
118
|
+
it "respects" do
|
119
|
+
expect(request.options[:proxy]).to eq("http://proxy.internal")
|
120
|
+
end
|
121
|
+
|
122
|
+
context "when option proxy set" do
|
123
|
+
let(:options) { {:proxy => nil} }
|
124
|
+
|
125
|
+
it "does not override" do
|
126
|
+
expect(request.options[:proxy]).to be_nil
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
113
130
|
end
|
114
131
|
|
115
132
|
describe "#eql?" do
|
@@ -150,7 +167,7 @@ describe Typhoeus::Request do
|
|
150
167
|
|
151
168
|
context "when different order" do
|
152
169
|
let(:other_options) {
|
153
|
-
{:headers => { 'User-Agent' => "Fubar" }, :verbose => true }
|
170
|
+
{:headers => { 'User-Agent' => "Fubar", 'Expect' => ""}, :verbose => true }
|
154
171
|
}
|
155
172
|
let(:other) { Typhoeus::Request.new(base_url, other_options)}
|
156
173
|
|
@@ -166,7 +183,7 @@ describe Typhoeus::Request do
|
|
166
183
|
context "when request.eql?(other)" do
|
167
184
|
context "when different order" do
|
168
185
|
let(:other_options) {
|
169
|
-
{:headers => { 'User-Agent' => "Fubar" }, :verbose => true }
|
186
|
+
{:headers => { 'User-Agent' => "Fubar", 'Expect' => "" }, :verbose => true }
|
170
187
|
}
|
171
188
|
let(:other) { Typhoeus::Request.new(base_url, other_options)}
|
172
189
|
|
@@ -211,4 +228,5 @@ describe Typhoeus::Request do
|
|
211
228
|
expect(request.encoded_body).to eq("a=1")
|
212
229
|
end
|
213
230
|
end
|
231
|
+
|
214
232
|
end
|
@@ -92,6 +92,19 @@ describe Typhoeus::Response::Header do
|
|
92
92
|
expect(header[name.downcase]).to eq(value)
|
93
93
|
end
|
94
94
|
end
|
95
|
+
|
96
|
+
context 'includes line with only whitespace' do
|
97
|
+
let(:raw) do
|
98
|
+
'HTTP/1.1 200 OK
|
99
|
+
Date: Fri, 29 Jun 2012 10:09:23 GMT
|
100
|
+
|
101
|
+
'
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'ignores it' do
|
105
|
+
expect(header).to eq({ 'Date' => 'Fri, 29 Jun 2012 10:09:23 GMT' })
|
106
|
+
end
|
107
|
+
end
|
95
108
|
end
|
96
109
|
end
|
97
110
|
end
|
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.1.0
|
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-07-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ethon
|