typhoeus 1.0.2 → 1.1.0

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: 209f15af78c352c7b5e54d1ad520d6a147eca869
4
- data.tar.gz: 1a0a2f51d4ea855c1f50d35036092a4a736abfee
3
+ metadata.gz: 0e844646bbdb137fea0fc50cf6c8d618ed1ef675
4
+ data.tar.gz: f2eef78a13606b8c957cae48afea61fe1118117b
5
5
  SHA512:
6
- metadata.gz: c4fcf5b5dd53cf4efd1eb01a96ec3f987fb494563f94a32338e9a97004bf2ba83b519499b8793d1f3b7a8fdfe331c1cafdff1c05c296d8c71d59193e19353e66
7
- data.tar.gz: f9b2ac78c68e374543404cdbbc34dfd3a64ff113f75bf5101a82fde17b62819ac8daebafc8e39d819cae88b7a94da071cf261f4febc0e68948449a375eb09da6
6
+ metadata.gz: 4e2cd0fdcdf92be70c916a75b95a8d3f6baf794e760c14f8dda7e0812ba965f686a9d720176e082e3cbe6b0cacd3013f79ea8f52deae7242f4728b44dc08b608
7
+ data.tar.gz: a76443341afde890cc9bfc6feb4e350effc9f8be7f36c5f61eb25d9afd0fcbeba182c675aa7a09bfb3ba514c6269543e4f0d2e5c81f0958c4986e0d9d06a9cd8
@@ -21,3 +21,4 @@ matrix:
21
21
  - rvm: ruby-head
22
22
  - rvm: jruby-head
23
23
  - rvm: ree
24
+ - rvm: rbx
@@ -2,7 +2,15 @@
2
2
 
3
3
  ## Master
4
4
 
5
- [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v1.0.2...master)
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("1.9.3")
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
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/typhoeus/typhoeus/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
@@ -92,6 +92,7 @@ module Faraday # :nodoc:
92
92
  end
93
93
  elsif resp.response_code == 0
94
94
  env[:typhoeus_connection_failed] = true
95
+ env[:typhoeus_return_message] = resp.return_message
95
96
  unless parallel?(env)
96
97
  raise Faraday::Error::ConnectionFailed, resp.return_message
97
98
  end
@@ -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
@@ -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
@@ -33,6 +33,7 @@ module Typhoeus
33
33
  end
34
34
  when String
35
35
  raw.lines.each do |header|
36
+ header.strip!
36
37
  next if header.empty? || header.start_with?( 'HTTP/1.' )
37
38
  process_line(header)
38
39
  end
@@ -1,5 +1,5 @@
1
1
  module Typhoeus
2
2
 
3
3
  # The current Typhoeus version.
4
- VERSION = '1.0.2'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -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.2
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-04-28 00:00:00.000000000 Z
13
+ date: 2016-07-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ethon